PHP&;GetText在我的服务器上工作不正常
我试图设置gettext来翻译我的网站,但我的服务器上不断出现奇怪的行为 在我的ubuntu机器上运行正常,但在我的centos 5.5专用服务器上,只有部分页面被翻译,当我刷新页面时,它实际上改变了翻译的部分 我知道这听起来很疯狂 apache日志中没有任何内容PHP&;GetText在我的服务器上工作不正常,php,gettext,Php,Gettext,我试图设置gettext来翻译我的网站,但我的服务器上不断出现奇怪的行为 在我的ubuntu机器上运行正常,但在我的centos 5.5专用服务器上,只有部分页面被翻译,当我刷新页面时,它实际上改变了翻译的部分 我知道这听起来很疯狂 apache日志中没有任何内容 “帮助,我迷路了:”(PHP中的Gettext有问题。-您可能遇到了一个问题 我无法提供修复或良好的调试方法,但: 制作一个测试脚本,运行所有已知的字符串。使用不同的字符集进行测试 尝试升级-如果是这样的话,从5.2升级到PHP5.
“帮助,我迷路了:”(PHP中的Gettext有问题。-您可能遇到了一个问题 我无法提供修复或良好的调试方法,但:
- 制作一个测试脚本,运行所有已知的字符串。使用不同的字符集进行测试
- 尝试升级-如果是这样的话,从5.2升级到PHP5.3
- 或者卸载php.ini中的gettext模块,改为通过
动态加载它。dl()
- 性能不好,但可能会减轻与运行时/内存相关的错误
- 不要使用gettext.so,但是脚本实现了php gettext或升级php gettext.php(权宜之计)
1b)如果您可以设置语言环境,请在没有shell的情况下尝试使用此代码
echo setlocale(LC_ALL, 0); // read the current locale
setlocale(LC_ALL, "fa"); // try to write your locale
echo setlocale(LC_ALL, 0); // check if your was accepted
2a)如果缺少区域设置,则添加该区域设置,例如使用“apt get install locales”。2b)如果您没有根权限,请使用作为替代
<?php
$locale = "fa";
// Define location and domain of translations
$directory = realpath('./') .'/translations/LOCALES';
$domain = 'php-addressbook';
$default_locale = $locale;
$supported_locales = array($locale);
// Prepare "php-gettext"
require_once('gettext/gettext.inc');
// Prepare "native gettext" setup
T_setlocale(LC_ALL, $locale);
T_bindtextdomain($domain, $directory);
T_textdomain($domain);
T_bind_textdomain_codeset($domain, 'UTF-8');
echo T_gettext('ADDRESS');
if (!locale_emulation()) {
print "<p>locale '$locale' is supported by your system, using native gettext implementation.</p>\n";
}
else {
print "<p>locale '$locale' is _not_ supported on your system, using the default locale '". $default_locale ."'.</p>\n";
}
?>
谢谢你的建议,我确实尝试过使用php gettext脚本,但我也有同样的行为。我最终更新到PHP5.3.6,问题似乎消失了。谢谢你的时间