私はこの問題にかなり長い間取り組んでおり、これが最初の質問ではありませんが、ローカリゼーションを正しく機能させることができません。私は WAMP サーバーと php gettext を使用しています。私の問題のデモンストレーションのために作成した簡単なコード:
/* dirs */
$directory = realpath('../locale');
$domain = 'messages';
/* trying to find out correct setting - last one is winner */
$locale ="ro";
$locale ="ro_utf8";
$locale ="ro_RO";
$locale ="ro_RO.UTF-8";
$locale ="Romanian_Romania.1250";
putenv("LANG=".$locale);
print setlocale( LC_ALL, $locale);
setlocale( LC_ALL, $locale);
bindtextdomain($domain, $directory);
textdomain($domain);
bind_textdomain_codeset($domain, 'UTF-8');
/* STRING TO BE TRANSLATED */
echo _('string');
ディレクトリには、この../locale
ような多くのフォルダーがあります - $language_name/LC_MESSAGES/
。これらには、対応する .po および . 次のような翻訳を含む mo ファイル:
msgid "string"
msgstr "string SK"
sk_SK
フォルダ内またはこれ
msgid "string"
msgstr "string RO"
、、、、、、、フォルダ内。 ro
_ ro_RO
_ ro_RO.UTF8
_ ro_RO.UTF-8
_romanian
Romanian_Romania
Romanian_Romania.1250
そして、どのようなドキュメントが見えますか:
Romanian_Romania.1250 文字列 SK
はっきりとわかるように、 locale() を romanianに設定しましたが、テキストはdirectoryの翻訳を使用して翻訳されていますsk_SK
。私は何を間違っていますか?
サーバーが期待する $locale 文字列とディレクトリ名に関する情報を取得するために使用できる関数はありますか?