PHP Gettext,总是试图打开英文翻译文件

时间:2014-12-14 12:26:26

标签: php apache gettext

好的,让我们直接进入代码,

PHP代码:

$locale = "Dutch_Netherlands.1252";
echo PHP_VERSION . "<br />";
echo (putenv("LC_ALL=$locale") ? "Success" : "Failure"). "<br />";
echo setlocale(LC_ALL, $locale) . "<br />";
echo bindtextdomain("messages", "C:\\Hello") . "<br />";
echo textdomain("messages") . "<br />";
echo gettext("Hello") . "<br />";

目录结构是:

C:\Hello\Dutch_Netherlands.1252\LC_MESSAGES\messages.mo
C:\Hello\Dutch_Netherlands.1252\LC_MESSAGES\messages.po

messages.po内容:

msgid ""
msgstr ""
"Project-Id-Version: messages\n"
"POT-Creation-Date: 2014-12-14 13:27+0330\n"
"PO-Revision-Date: 2014-12-14 15:41+0330\n"
"Last-Translator: xxxxxxxxxxxx\n"
"Language-Team: \n"
"Language: nl_NL\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=windows-1252\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.7.1\n"
"X-Poedit-Basepath: .\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#: ..\..\..\xxxxxx:531
msgid "Hello"
msgstr "LOADED"

输出:

5.5.12
Success
Dutch_Netherlands.1252
C:\Hello
messages
Hello

Process Monitor结果:

httpd.exe QueryDirectory   C:\Hello                                  SUCCESS
httpd.exe CreateFile       C:\Hello\en_US\LC_MESSAGES\messages.mo    PATH NOT FOUND: Desired Access: Generic Read, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: n/a
httpd.exe CreateFile       C:\Hello\en\LC_MESSAGES\messages.mo       PATH NOT FOUND: Desired Access: Generic Read, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: n/a

我无法看到上述代码无效的原因。所以我在这里问你是否有什么我不知道的。一切顺利,但Apache希望阅读英文版。

Windows 7 SP1 x64

1 个答案:

答案 0 :(得分:0)

根据我的测试和搜索,

这是Apache在x64版本的Windows上的常见问题,

我不确定这个错误是在PHP,GetText库还是Apache中,但它是一个严重的错误。

目前使用32位版本的Wamp可以解决问题。我没有找到VS.Php的默认Web服务的解决方法。