开发者

Gettext, not displaying

开发者 https://www.devze.com 2022-12-09 12:59 出处:网络
I\'m trying to load my .mo translations using the following code, but it doesn\'t work. I have the php gettext ext. enabled in my phpinfo() and all the requi开发者_运维技巧red locales are installed.

I'm trying to load my .mo translations using the following code, but it doesn't work. I have the php gettext ext. enabled in my phpinfo() and all the requi开发者_运维技巧red locales are installed. Did I miss anything?

$locale = "en_US";

putenv("LC_ALL=$locale");

setlocale(LC_ALL, $locale);

bindtextdomain("messages", "./locale");
textdomain("messages");

My .mo file is located in ./locale/en_US/messages.mo


When an apache thread loads an .mo file, it will not reload it until the apache thread is recycled. So if you update the .mo file, and want to be sure that your php is using that new .mo file, you actually need to either restart apache or use a different name for the mo file.

Anyway, I would set the LANG environment variable.


You probably need to change the path so that it is absolute, instead of relative.

0

精彩评论

暂无评论...
验证码 换一张
取 消