翻译不适用于Poedit&腓

时间:2014-01-29 04:24:08

标签: php gettext poedit

我一直在尝试使用以下代码来翻译Poedit& PHP。这是一个非常基本的例子,我试图用德语翻译。我有以下文件夹中的文件。

/home/test/test.php
/home/test/localization.php
/home/test/locale/de_DE/LC_MESSAGES/default.po
/home/test/locale/de_DE/LC_MESSAGES/default.mo

test.php的

require_once("localization.php");
echo _("Hello World!");

localization.php

$locale = "de_DE";

if (isset($_GET["locale"])) 
    $locale = $_GET["locale"];

putenv("LC_ALL=$locale");

setlocale(LC_ALL, $locale);

bindtextdomain("default", "./locale");

textdomain("default");

当我运行localhost:8080/test/test.php时,它只显示英文消息"Hello World!"。我翻译成default.po。这是:

msgid ""
msgstr ""
"Project-Id-Version: a\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-01-29 09:37+0530\n"
"PO-Revision-Date: 2014-01-29 09:38+0530\n"
"Last-Translator: Rahul <rahul@gmail.com>\n"
"Language-Team: b <a@b.com>\n"
"Language: \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: .\n"
"X-Poedit-Language: German\n"
"X-Poedit-Country: GERMANY\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-SearchPath-0: .\n"

#: test.php:4
msgid "Hello World!"
msgstr "Hallo Welt!"

我出错的任何想法?提前谢谢。

0 个答案:

没有答案