获取文本 PHP5 在 debian 上不起作用 [英] get text PHP5 don't work on debian

查看:42
本文介绍了获取文本 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_USlocale-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 上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆