Zend framework2 ZF2如何更改视图中的区域设置

Zend framework2 ZF2如何更改视图中的区域设置,zend-framework2,zend-translate,Zend Framework2,Zend Translate,我的配置是 'translator' => array( 'locale' => 'en_EN', 'translation_file_patterns' => array( array( 'type' => 'gettext', 'base_dir' => __DIR__ . '/../language', 'pattern' => '%s.mo', ), ),

我的配置是

'translator' => array(
'locale' => 'en_EN',
'translation_file_patterns' => array(
    array(
        'type'     => 'gettext',
        'base_dir' => __DIR__ . '/../language',
            'pattern'  => '%s.mo',
        ),
    ),
),
以及如何从视图或控制器更改区域设置?

获取转换器实例并调用setLocale方法。控制器上下文示例:

// Get the translator from the service locator.
$translator = $this->getServiceLocator()->get('translator');
$translator->setLocale($myLocale);
获取转换器实例并调用setLocale方法。控制器上下文示例:

// Get the translator from the service locator.
$translator = $this->getServiceLocator()->get('translator');
$translator->setLocale($myLocale);
更新:

$translator = $this->getServiceLocator()->get('translator');
$translator->setLocale($myLocale);
更新:

$translator = $this->getServiceLocator()->get('translator');
$translator->setLocale($myLocale);

我认为代码应该是这样的$this->getServiceLocator->getTranslator;这很好,但只有当$myLocale变量的值为en_US或法语-fr_fr时才可以。我想知道如果值为fr,我应该怎么做。我的url是domain.com/fr/。我认为代码应该是这样的$This->getServiceLocator->get'translator';这很好,但只有当$myLocale变量的值为en_US或法语-fr_fr时,才可以使用。我想知道如果值为fr,我应该怎么做。我的url是domain.com/fr/。。