无法使(UTF-8)繁体中文字符在PHP gettext扩展中工作(.po和.mo文件在poEdit中创建)

ale*_*nco 5 encoding character cjk poedit

我检查了MSDN,语言环境字符串是zh_Hant,但我也试过了zh_TW(中文,台湾).

繁体中文字符在poEditor中看起来不错,但是当我在浏览器中打开文件时,字符只是奇怪的符号(«¢Å¥¥¬É!).我认为翻译工作正常,但编码有问题(我使用了字符集和源代码字符集的UTF-8).

使用poEditor生成的文件:

messages.po:

msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2010-02-15 16:26+0800\n"
"PO-Revision-Date: 2010-02-15 16:26+0800\n"
"Last-Translator: Jano Chen <weedcl@hotmail.com>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-KeywordsList: _;gettext;gettext_noop\n"
"X-Poedit-Basepath: C:\\wamp\\www\\php-test\n"
"X-Poedit-Language: Chinese\n"
"X-Poedit-Country: TAIWAN\n"
"X-Poedit-SourceCharset: utf-8\n"
"X-Poedit-SearchPath-0: .\n"

#: test.php:3
msgid "Hello World!"
msgstr "????!"
Run Code Online (Sandbox Code Playgroud)

PS:当我将Firefox中的编码显示更改为Big5时,字符显示正确,但如果我将它们更改为UTF-8则会显示: o @ !.

ale*_*nco 9

我终于解决了.我必须有以下文件来local.php.

bind_textdomain_codeset("messages", 'UTF-8');
Run Code Online (Sandbox Code Playgroud)