[英]PHP gettext does not work
Gettext simply does not work for me: Gettext根本不适合我:
putenv('LC_ALL=zh_CN.utf8');
setlocale(LC_ALL, 'zh_CN.utf8');
bindtextdomain('messages', __DIR__.'/locale');
textdomain('messages');
messages.mo location is locale/zh_CN.utf8/LC_MESSAGES. messages.mo的位置是locale / zh_CN.utf8 / LC_MESSAGES。
$locale -a
C
en_AG
en_US.utf8
en_ZA.utf8
en_ZW.utf8
POSIX
zh_CN.utf8
zh_SG.utf8
I'm on Ubuntu. 我在Ubuntu上。
Any idea? 任何想法?
Judging this note , you are most likely missing UTF-8 bits. 从此注释来看,您很可能会丢失UTF-8位。 Those helped me with problem of “Gettext not working”.
这些帮助我解决了“ Gettext无法正常工作”的问题。
$directory = dirname(__FILE__).'/locale';
$domain = 'mydomain';
$locale ="fi_FI.utf8";
//putenv("LANG=".$locale); //not needed for my tests, but people say it's useful for windows
setlocale( LC_MESSAGES, $locale);
bindtextdomain($domain, $directory);
textdomain($domain);
bind_textdomain_codeset($domain, 'UTF-8');
Inside locale, there should be file structure of 在语言环境中,应该有以下文件的结构
./locale/pt/LC_MESSAGES/mydomain.mo
or similar. 或类似。
Important: If the mo file is already read by Apache, it needs be restarted so that it can read the new file. 重要说明:如果Apache已经读取了mo文件,则需要重新启动它,以便它可以读取新文件。 In other words, there is some kind of caching system I don't know about still.
换句话说,有一些我仍然不知道的缓存系统。
对我而言,它通过重新启动apache起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.