Unable to get (UTF-8) traditional Chinese character to work in PHP gettext extension (.po and .mo files created in poEdit)

I checked MSDN and the locale line is zh_Hant, but I also tried with zh_TW (Chinese, Taiwanese).

Traditional Chinese characters look OK in poEditor, but when I open the file in the browser, the characters are just weird characters ("Β’ Γ…o Β₯ @ ƒ!). I think the translation works, but something is wrong with the encoding (I used UTF-8 for Charset and Source Code Charset encoding).

Files created 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 screen in Firefox to Big5, the characters are displayed correctly, but if I reassign them to UTF-8, then it shows: o @ !.

+5
source share
1 answer

I finally decided. I should have had the following localization.php file.

 bind_textdomain_codeset("messages", 'UTF-8'); 
+9
source

Source: https://habr.com/ru/post/889416/


All Articles