我跟着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