get text PHP5 don#39;t work on debian(获取文本 PHP5 在 debian 上不起作用)
问题描述
我正在开发一个使用 gettext 的网站.每件事在当地都很好用.但是今天我已经在我的生产服务器上上传了我的网站,gettext 不想再工作了.我想使用的语言是 fr_FR 和 en_US.如果我用法语显示我的网站,gettext 会翻译我的文本,但英语没有任何反应.
I'm developing a web site which use gettext. Every thing work great in local. But today I've upload my web site on my production server and gettext don't want to work anymore. The language I'd like to use are fr_FR and en_US. gettext translate my text if I display my web site in french but nothing happen for the english.
当我在我的 debian 服务器上执行 locale -a 时,我得到:
When I execute locale -a on my debian server, I get:
C
fr_FR.utf8
POSIX
我是法国人,所以我认为一切都很正常.但是当我这样做时: locale-gen en_US 或 locale-gen en_US.UTF-8 然后再次 locale -a ,没有任何改变.!这正常吗?
I'm french so I think every thing is normal. But when I do: locale-gen en_US or locale-gen en_US.UTF-8 and then locale -a again, nothing change. ! Is that normal ?
这是一个 PHP 代码示例,以防万一.但是由于 gettext 适用于法语,我相信问题不在这里.
Here is a sample of PHP code just in case. But since gettext work for the french language, I believe the problem is not here.
$langage = 'en_US.utf8';
putenv("LC_ALL=$langage");
setlocale(LC_ALL, $langage);
$languageFileName = "default"; // locale/en_US/LC_MESSAGES/default.mo
bindtextdomain($languageFileName, PATH.'/locale');
bind_textdomain_codeset($languageFileName, 'UTF-8');
textdomain($languageFileName);
非常感谢您的帮助.
推荐答案
好吧,我找到了解决问题的方法.我已编辑文件 /etc/locale.gen 并取消注释我想与 gettext 一起使用的语言.然后我运行了 locale-gen.就是这样!
Well, I've find the solution to my problem. I've edited the file /etc/locale.gen and uncomment the language I'd like to use with gettext. Then I've run locale-gen. That's it !
仍然不明白为什么 locale-gen en_US.UTF-8 没有做同样的事情.我正在使用 debian 6 Squeeze.
Still don't understand why locale-gen en_US.UTF-8 didn't do the same thing. I'm using debian 6 Squeeze.
这篇关于获取文本 PHP5 在 debian 上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:获取文本 PHP5 在 debian 上不起作用


- 没有作曲家的 PSR4 自动加载 2022-01-01
- 带有通配符的 Laravel 验证器 2021-01-01
- 从 PHP 中的输入表单获取日期 2022-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01
- Laravel 仓库 2022-01-01
- 如何定位 php.ini 文件 (xampp) 2022-01-01
- 正确分离 PHP 中的逻辑/样式 2021-01-01
- SoapClient 设置自定义 HTTP Header 2021-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01