Windows上的PHP gettext [英] PHP gettext on Windows

查看:86
本文介绍了Windows上的PHP gettext的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一些关于gettext的教程(使用Poedit)...不幸的是,它主要用于UNIX环境.甚至更不幸的是,我在Windows XP上运行WAMP服务器(但是我正在为UNIX环境开发),而所有教程都无法使gettext对我来说正常工作.在手册页中,看来这是一个不同的过程Windows环境.我已经尝试了评论中的一些解决方案,但仍然无法正常工作!我为此花费了许多时间,希望有人可以指出正确的方向,以使此功能正常工作! (而且我敢肯定还有其他人对此感到沮丧.)到目前为止,在我的设置中,我只得到输出"Hello World!".而我应该得到翻译后的字符串.

There are some tutorials out there for gettext (with Poedit)... unfortunately, it's mostly for a UNIX environment. And even more unfortunate is that I am running my WAMP server on Windows XP (but I am developing for a UNIX environment) and none of the tutorials can get gettext working properly for me. From the manual page, it appears that it's a different process on a Windows environment. I've tried out some of the solutions in the comments but I still can't get it to work! I've spent many hours on this, hopefully someone can point me in the right direction to get this thing to work! (And I'm sure there are others out there who share my frustration.) So far with my setup, I'm only getting output "Hello World!" whereas I should be getting the translated string.

到目前为止,这是我的设置/代码:

Here is my setup/code so far:

// test.php
if (!defined('LC_MESSAGES')) {
    define('LC_MESSAGES', 6);
}

$locale = "deu_DEU"; // apparently the locales are different on a WINDOWS platform

putenv("LC_ALL=$locale");
setlocale(LC_ALL, $locale);
bindtextdomain("greetings", ".\locale");
textdomain("greetings");

echo _("Hello World"); 

文件夹结构


root:     C:\Program Files\WampServer 2\www
test.php: C:\Program Files\WampServer 2\www\site
.po:      C:\Program Files\WampServer 2\www\site\locale\deu_DEU\LC_MESSAGES\greetings.po
.mo:      C:\Program Files\WampServer 2\www\site\locale\deu_DEU\LC_MESSAGES\greetings.mo

推荐答案

这是因为我没有安装语言环境.

It was because I didn't have the locales installed.

这篇关于Windows上的PHP gettext的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆