我跟着folling教程:http://mel.melaxis.com/devblog/2005/08/06/localizing-php-web-sites-using-gettext/Php gettext不显示翻译后的文本(使用poEdit生成.pot和.mo文件后)!
关于PHP的gettext扩展(我未选中在php.ini评论)
了gettext被激活,但它并没有显示出来的翻译(德国)。
以下是文件:
C:\ WAMP \ WWW \ PHP测试\ test.php的:
<?php
require_once("localization.php");
echo _("Hello World!");
?>
C:\ WAMP \ WWW \ PHP测试\本地化.PHP:
<?php
$locale = "de_DE";
if (isSet($_GET["locale"])) $locale = $_GET["locale"];
putenv("LC_ALL=$locale");
setlocale(LC_ALL, $locale);
bindtextdomain("messages", "./locale");
textdomain("messages");
?>
C:\瓦帕\ WWW \ PHP-测试\区域\ de_DE这个\ LC_MESSAGES \ messages.po:
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2010-02-14 00:35+0800\n"
"PO-Revision-Date: 2010-02-14 00:37+0800\n"
"Last-Translator: Jano Chen <[email protected]>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-KeywordsList: _;gettext;gettext_noop\n"
"X-Poedit-Basepath: C:\\wamp\\www\\php-test\n"
"X-Poedit-Language: German\n"
"X-Poedit-Country: GERMANY\n"
"X-Poedit-SourceCharset: iso-8859-1\n"
"X-Poedit-SearchPath-0: .\n"
#: test.php:2
msgid "Hello World!"
msgstr "Hallo Welt!"
C:\ WAMP \ WWW \ PHP测试\区域\ de_DE这个\ LC_MESSAGES \ messages.mo
(对不起,因为某种原因,我不能复制该文件的文本)
alt text http://img202.imageshack.us/img202/8892/mofile.png
当我打开它应该显示“喂世界报”(世界您好在德国),而是它显示在英语(你好世界)。
有什么建议吗?
PS:我使用Windows XP SP2
所有你需要做的就是重启Apache – 2017-10-05 13:03:58