I'm trying to support traditional chinese in one of my PHP projects, but I can't get it to show any chinese characters. Here's my gettext setup:
putenv("LC_ALL=zh_CN.utf8");
setlocale(LC_ALL, "zh_CN.utf8");
bindtextdomain("wpsmessages", dirname(__FILE__) . "/locale");
bind_textdomain_codeset("wpsmessages", 'UTF-8');
textdomain("wpsmessages");
Earlier I created the locale in SSH by typing:
sudo locale-gen zh_CN.utf8
Which then returned:
Generating locales...
zh_CN.UTF-8... done
After typing locale -a
I get the follwing in the list (among others):
zh_CN
zh_CN.utf8
But still, it doesn't show any chinese characters. What am I doing wrong here?
A little emberrassing, but the solution was simply renaming the file
wpsmessages-zh_CN.mo
towpsmessages.mo
following my own file name conventions.Basically the structure of my PHP project using gettext is like this:
So using
bindtextdomain("wpsmessages", dirname(__FILE__) . "/locale");
gets the correct.mo
file for a locale specified bysetlocale()
, but it couldn't find the file as it's name was wrong.Hope this helps anyone being as stupid as me. :)