This is a little code snippet from php manual:
putenv('LC_ALL=zh_CN');
setlocale(LC_ALL, 'zh_CN');
bindtextdomain('domain', './locale');
textdomain('domain');
echo gettext('Hello');
Which will output 你好 as defined in domain.mo
file, but the problem is as long as the Apache is running, gettext()
always return the cached result.
If I change the translation of Hello to 您好 in domain.mo
, it will still output 你好.
However there is a fix for this by changing the domain
argument of bindtextdomain()
and textdomain()
to a new name. Like from "domain"
to "domain2"
. But this is really painful to edit the php file every time I updated the .mo
file.
Is there a better way for doing this, like remove some folders or calling some php functions to do the job? So that I can write a little script for this purpose.