donglie1994 2017-08-23 10:14
浏览 83

php gettext返回msgid字符串

I'm following the tutorial here, php is outputting the msgid instead of the msgstr. Here is what I have...

extension=php_gettext.dll uncommented in php.ini (this was already uncommented in xampp)

php_gettext.dll in C:\xampp\php\ext (this was already in xampp)

Directory structure C:\xampp\htdocs\TestI18N\Locale\en_US\LC_MESSAGES with created messages.po and messages.mo files in LC_MESSAGES.

A file called test-locale.php in C:\xampp\htdocs\TestI18N with the following

// I18N support information here
$language = "en_US";
putenv("LANG=" . $language); 
setlocale(LC_ALL, $language);

// Set the text domain as "messages"
$domain = "messages";
bindtextdomain($domain, "Locale"); 
bind_textdomain_codeset($domain, 'UTF-8');

textdomain($domain);

echo _("HELLO_WORLD");

My messages.po file

msgid ""
msgstr ""
"Project-Id-Version: TestProject
"
"POT-Creation-Date: 2017-08-22 23:42+0300
"
"PO-Revision-Date: 2017-08-22 23:53+0300
"
"Last-Translator: 
"
"Language-Team: English
"
"MIME-Version: 1.0
"
"Content-Type: text/plain; charset=UTF-8
"
"Content-Transfer-Encoding: 8bit
"
"X-Generator: Poedit 2.0.3
"
"X-Poedit-Basepath: .
"
"Plural-Forms: nplurals=2; plural=(n != 1);
"
"Language: en_US
"
"X-Poedit-SourceCharset: UTF-8
"

# Test token 1
msgid "HELLO_WORLD"
msgstr "Hello World!"

# Test token 2
msgid "TEST_TRANSLATION"
msgstr "Testing translation..."

The output is HELLO_WORLD. What am I doing wrong? Thanks.

  • 写回答

1条回答 默认 最新

  • doomli3721 2019-08-08 21:16
    关注

    I understand this question is old but in case it helps anyone else; the locale installed on my server was en_US.utf8 as opposed to just en_US.

    评论

报告相同问题?

悬赏问题

  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思