简体   繁体   中英

PHP Gettext, always tries to open English translation file

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\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"

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM