0

在我的应用程序中,我使用服务语言。在我的 module.php 中,我通过以下方法设置用户的语言环境:

$translator = $e->getApplication()->getServiceManager()->get('translator');
$translator ->setLocale(\Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']))
            ->setFallbackLocale($this->setDomainLocale());

在这个应用程序上有运行服务器 domain.tdl(不同的语言)所以我在我的后备中使用一个函数来设置每个域的后备语言环境,无论如何......

我想使用currencyFormat,但我无法将它与用户的语言环境一起使用。我尝试了下面的代码,有无 '\Locale::getDefault())'; 像“1509053”这样的数字应该返回为“€ 1.509.053.00”或“,”取决于语言环境,我只得到“€ 1509053.00”。

$this->plugin("currencyformat")->setCurrencyCode("EUR")->setLocale(\Locale::getDefault());

\Locale::getDefault() 的输出

string(11) "en_US_POSIX"

module.php $translator 的输出

   class Zend\I18n\Translator\Translator#193 (8) { protected $messages => array(0) { } 
protected $files => array(0) { } protected $patterns => array(1) { 'default' => array(1) { [0] => array(3) { 'type' => string(7) "gettext" 'baseDir' => string(119) "..../module/.../config/../language" 'pattern' => string(5) "%s.mo" } } } protected $remote => array(0) { } protected $locale => string(35) "nl-NL,nl;q=0.8,en-US;q=0.6,en;q=0.4" protected $fallbackLocale => string(5) "nl_NL" protected $cache => NULL protected $pluginManager => NULL }

希望有人能让我朝着正确的方向前进:) Thnx

4

1 回答 1

0

使用函数 '\Locale::getDefault();' 我们需要先设置 '\Locale::setDefault(language_code);' $translate->setLocale 没有设置 Locale::getDefault();。

于 2013-01-09T14:56:18.297 回答