Php can';无法使区域设置在Linux上工作
我正在编写一个PHP应用程序,并使用gettext模块翻译成不同的语言 代码在我的本地计算机(运行WAMP的Windows)上正常工作,但在服务器(Unix+apache2)上无法正常工作 我以前运行过“sudo locale get he_IL”和“sudo locale get he_IL.UTF-8”来安装语言组件 翻译正在本地(Windows)计算机上运行,但在服务器上显示原始字符串(未翻译)Php can';无法使区域设置在Linux上工作,php,linux,unix,locale,Php,Linux,Unix,Locale,我正在编写一个PHP应用程序,并使用gettext模块翻译成不同的语言 代码在我的本地计算机(运行WAMP的Windows)上正常工作,但在服务器(Unix+apache2)上无法正常工作 我以前运行过“sudo locale get he_IL”和“sudo locale get he_IL.UTF-8”来安装语言组件 翻译正在本地(Windows)计算机上运行,但在服务器上显示原始字符串(未翻译) 我还需要配置其他内容吗?尝试在Linux计算机上运行locale-a,以检查该区域设置是否正确
我还需要配置其他内容吗?尝试在Linux计算机上运行locale-a,以检查该区域设置是否正确安装,除非与挑剔级别相关:这是什么发行版?这可能更适合作为对问题的评论,而不是回答。运行locale-a不会回答问题,它只会给我们提供帮助我们回答问题的信息。
{
$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");
}