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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题