我使用gettext _('someString')
来执行 i18n ,它在我的windows dev XAMPP平台上运行正常;
但是,当我上传到Linux CentOS主机时,我的程序会显示非utf-8字符串的翻译。
例如,在中文版中,它显示�Τ�
而不是用戶
(浏览器编码为UTF8)
如果我将浏览器编码更改为BIG5,我可以看到标签是用户。
这是我的messages.po文件(ANSI as UTF-8):
msgid ""
msgstr ""
"Project-Id-Version: ERP\n"
"POT-Creation-Date: 2014-04-25 14:50+0800\n"
"PO-Revision-Date: 2014-04-28 09:50+0800\n"
"Language-Team: \n"
"Language: zh_HK\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.5.7\n"
"X-Poedit-KeywordsList: _;gettext;gettext_noop\n"
"X-Poedit-Basepath: .\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: C:\xampp\test.php:34
msgid "User"
msgstr "用戶"
非常感谢你
答案 0 :(得分:0)
我终于找到了解决方案。在Linux中,语言环境文件夹必须是zh_HK.ut8
(我使用的是zh_HK),因为linux有3个类似的语言环境:zh_HK
zh_HK.big5hkscs
zh_HK.utf8