私のアプリケーションでは、サーバル言語を使用しています。私は私の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