无法使(UTF-8)繁体中文字符在 PHP gettext 扩展中工作(在 poEdit 中创建的 .po 和 .mo 文件)
我检查了 MSDN ,区域设置字符串是 zh_Hant,但我也尝试了 zh_TW(中文,台湾) 。
繁体中文字符在 poEditor 中看起来不错,但当我在浏览器中打开文件时,这些字符只是奇怪的符号(«∩o¥@∇É!)。我认为翻译是有效的,但编码有问题(我对字符集和源代码字符集都使用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 <[email protected]>\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 "哈囉世界!"
PS:当我将 Firefox 中的编码显示更改为 Big5 时,字符会正确显示,但如果我将它们更改为 UTF-8,则会显示: ���o�@��!.
I checked MSDN and the locale string is zh_Hant, but I also tried with zh_TW (Chinese, Taiwan).
The traditional Chinese characters look OK in the poEditor, but when I open the file in the browser the characters are just weird symbols («¢Åo¥@¬É!). I think the translation is working, but there's something wrong with the encoding (I used UTF-8 for both Charset and Source Code Charset).
The files generated with 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 <[email protected]>\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 "哈囉世界!"
PS: When I change the encoding display in Firefox to Big5 the characters are shown properly, but if I change them to UTF-8 it shows: ���o�@��!.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我终于解决了。我必须将以下内容写入 localization.php 文件。
I finally solved it. I had to have the following to file localization.php.