我正在尝试使用gettext()来构建一个多语言的PHP Web应用程序。
这就是我的所作所为:
检查了我的php.ini文件,并启用了gettext
extension=php_gettext.dll
检查是否使用function_exists()安装了gettext()
我正在学习本教程:https://blog.udemy.com/php-gettext/
这是我的.po文件:
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2017-06-09 15:45+0530\n"
"PO-Revision-Date: 2017-06-09 17:07+0530\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.0.2\n"
"X-Poedit-Basepath: .\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Language: en_US\n"
# Test1
msgid "Hello"
msgstr "Hallo"
这是我的.php文件
$language = "en_US";
putenv("LANG=".$language);
setlocale(LC_ALL, $language);
//Set the text domain as messages
$domain = "messages";
bindtextdomain($domain, "Locale");
textdomain($domain);
echo gettext("Hello");
任何形式的帮助都会很明显。