gettext 问题 php
Issues with gettext php
无法通过 gettext 进行文本翻译。请帮助我
$translate = 'messages';
putenv("LC_ALL=en_US");
T_setlocale(LC_ALL, "en_US");
bindtextdomain($translate, _ROOT_DIR_."locale/");
textdomain($translate);
bind_textdomain_codeset($translate, 'UTF-8');
文件夹结构:
locale ->
en_US ->
LC_MESSAGES ->
messages.mo
messages.po
脚本 messages.po:
msgid ""
msgstr ""
"POT-Creation-Date: 2017-05-03 15:53+0300\n"
"PO-Revision-Date: 2017-05-03 15:54+0300\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.1\n"
"X-Poedit-Basepath: .\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Language: en_US\n"
#: index.php:5
msgid "Bonjour tout le monde"
msgstr "Hello world"
您只需在 php.ini 文件中注释掉一行。像这样-
;extension=php_gettext.dll
无法通过 gettext 进行文本翻译。请帮助我
$translate = 'messages';
putenv("LC_ALL=en_US");
T_setlocale(LC_ALL, "en_US");
bindtextdomain($translate, _ROOT_DIR_."locale/");
textdomain($translate);
bind_textdomain_codeset($translate, 'UTF-8');
文件夹结构:
locale -> en_US -> LC_MESSAGES -> messages.mo messages.po
脚本 messages.po:
msgid ""
msgstr ""
"POT-Creation-Date: 2017-05-03 15:53+0300\n"
"PO-Revision-Date: 2017-05-03 15:54+0300\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.1\n"
"X-Poedit-Basepath: .\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Language: en_US\n"
#: index.php:5
msgid "Bonjour tout le monde"
msgstr "Hello world"
您只需在 php.ini 文件中注释掉一行。像这样-
;extension=php_gettext.dll