获取文本PHP5不适用于debian [英] get text PHP5 don't work on debian

查看:158
本文介绍了获取文本PHP5不适用于debian的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个使用gettext的网站。每件事情在当地都很棒。但是今天我把我的网站上传到我的生产服务器上,而gettext不想再工作了。
我想使用的语言是fr_FR和en_US。
gettext翻译我的文本,如果我显示我的网站在法国,但没有发生的英文。



当我在我的debian服务器上执行 locale -a 时,我得到:

  C 
fr_FR.utf8
POSIX

我是法国人,所以我认为每件事情都是正常的。但是当我这样做: locale-gen en_US locale-gen en_US.UTF-8 ,然后再次 locale -a ,没有任何变化。 !这是正常吗?



以下是一些PHP代码示例,以防万一。但是由于gettext为法语工作,我相信问题不在这里。

  $ 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 。就是这样!



仍然不明白为什么 locale-gen en_US.UTF-8 没有做同样的事情。
我正在使用debian 6 Squeeze。


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.

When I execute locale -a on my debian server, I get:

C
fr_FR.utf8
POSIX

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 ?

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);

Thanks a lot in advance for the help.

解决方案

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 !

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天全站免登陆