我试图在运行php 7.1的CentOS服务器上用php设置国际化。
这是我的目录结构:
/home/project/public_html/locale/japanese/LC_MESSAGES/messages.po
/home/project/public_html/locale/japanese/LC_MESSAGES/messages.mo
/home/project/public_html/index.php
messages.po包含行(以及其他行):
"Language: japanese\n"
"Content-Type: text/plain; charset=UTF-8\n"
我有以下代码:
$check_putenv = putenv("LC_ALL=japanese");
if (!$check_putenv) {
echo "Warning: putenv LC_ALL failed!\n";
}
$check_putenv2 = putenv("LANGUAGE=japanese");
if (!$check_putenv2) {
echo "Warning: putenv LANGUAGE failed!\n";
}
$check_locale = setlocale(LC_MESSAGES, 'japanese');
if (!$check_locale) {
echo "Warning: Failed to set locale japanese!\n";
}
$check_bind = bindtextdomain("messages", "/home/project/public_html/locale");
if (!$check_bind) {
echo "Warning: Failed to bind text domain!\n";
}
$check_textdomain = textdomain("messages");
if ($check_textdomain !== "messages") {
echo "Warning: Failed to set text domain!\n";
}
输出是
Warning: Failed to bind text domain!
区域设置-返回(以及其他)
ja_JP
ja_JP.utf8
japanese
知道会出什么问题吗?