无法在Linux上进行区域设置工作
问题描述:
我正在编写一个PHP应用程序并使用gettext模块转换为不同的语言。无法在Linux上进行区域设置工作
的代码工作,我希望我的本地计算机上(Windows上运行WAMP),但我不能让它工作在服务器上(在Unix +的Apache2)
{
$locale_folder = dirname(dirname(dirname(__FILE__))).'/locale/';
$locale = 'he_IL';
$domain = 'myapp';
$autoreload = true;
// activate the locale setting
setlocale(LC_ALL, $locale);
setlocale(LC_TIME, $locale);
putenv("LANG=$locale");
putenv("LANGUAGE=$locale");
putenv("LC_ALL=$locale");
putenv("LC_MESSAGES=$locale");
if ($autoreload) {
// path to the .MO file that we should monitor
$filename = "$locale_folder/$locale/LC_MESSAGES/$domain.mo";
$mtime = filemtime($filename); // check its modification time
// our new unique .MO file
$filename_new = "$locale_folder/$locale/LC_MESSAGES/{$domain}_{$mtime}.mo";
if (!file_exists($filename_new)) { // check if we have created it before
// if not, create it now, by copying the original
copy($filename,$filename_new);
}
// compute the new domain name
$domain_new = "{$domain}_{$mtime}";
} else {
$domain_new = $domain;
}
// bind it
bindtextdomain($domain_new,$locale_folder);
// then activate it
textdomain($domain_new);
bind_textdomain_codeset($domain_new, "UTF-8");
}
我已经运行“命令的语言环境-get he_IL“和”sudo locale-get he_IL.UTF-8“以安装语言组件。
翻译工作的地方(Windows)中的计算机上,但显示在服务器上的原始字符串(没有翻译)......
我一定要配置什么吗?
答
尝试你的Linux机器上运行的locale -a命令来检查是否正确安装相关挑剔的水平之上
+0
这可能会更适合作为对问题的评论,而不是回答。运行区域设置-a不会回答问题,它只会给我们提供信息来帮助我们回答问题。 – 2011-05-17 16:49:05
Perhpas的语言环境:什么分布是这样吗? – sehe 2011-05-06 19:38:49