douwei1904
2014-12-14 12:26
浏览 68
已采纳

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

Ok, Let go right to the code,

PHP Code:

$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 />";

Directory structure is:

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

messages.po contents:

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

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

Output:

5.5.12
Success
Dutch_Netherlands.1252
C:\Hello
messages
Hello

Process Monitor results:

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

I cant see any reason for the above code to not work. So here I am to ask you if you see anything I dont. Everything goes smooth and yet Apache wants to read the English version.

Windows 7 SP1 x64

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongyuelian9602 2014-12-16 00:34
    已采纳

    Based on my tests and searches,

    It is a common problem with Apache on x64 versions of Windows,

    I am not sure if this bug is in PHP, GetText library or Apache, but it is a serious bug.

    For now using 32bit version of Wamp can solve the problem. I found no workaround for VS.Php's default webservice.

    已采纳该答案
    打赏 评论

相关推荐 更多相似问题