zend framework2 - ZF2 CurrencyFormat在默认语言环境不工作



在我的应用程序中,我使用几种语言。在我的module.php中,我通过以下方法设置用户的区域设置:

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

有正在运行的服务器域。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的输出

   class ZendI18nTranslatorTranslator#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 }

希望有人能给我正确的方向:)谢谢

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

最新更新