5

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 <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 "哈囉世界!"

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�@��!.

Makoto
  • 104,088
  • 27
  • 192
  • 230
alexchenco
  • 53,565
  • 76
  • 241
  • 413

1 Answers1

11

I finally solved it. I had to have the following to file localization.php.

bind_textdomain_codeset("messages", 'UTF-8');
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
alexchenco
  • 53,565
  • 76
  • 241
  • 413
  • I was working on this for hours. Thank you!! For anyone having this issue, the first param of `bind_textdomain_codeset()` should be set to whatever you set with `textdomain()`. If you used `textdomain('messages')` then you would use the code in alexchenco's example above. – Gavin Feb 23 '14 at 22:47