英文到俄文翻译的字符编码问题


Character encoding problems with English to Russian translation

我使用Poedit(在Win7上运行)生成。mo/。po文件,使一个俄语版本的网页使用PHP gettext。当我显示俄语版本的页面时,所有字符都显示为黑色菱形/正方形。

下面是演示这个问题的示例网页:

http://cthorn.co.uk/localization/index.php

…以下是俄文版本:

http://cthorn.co.uk/localization/index.php?语言环境= ru_RU

index.php的代码为:

<?php require_once("locale/localization.php"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
        <title>Test</title>
    </head>
    <body>
        <p><? echo _("This is the text to be translated."); ?></p>
    </body>
</html>

文件localization.php的代码为:

<?php
    $locale = "en_GB";
    if (isSet($_GET["locale"])) $locale = $_GET["locale"];
    putenv("LC_ALL=$locale");
    setlocale(LC_ALL, $locale);
    bindtextdomain("messages", "./locale");
    textdomain("messages");
?>

目录结构为:

 - localization
    - locale
       - ru_RU
          - LC_MESSAGES
               messages.mo
               messages.po
         localization.php
      index.php

在Poedit中,我将"字符集"answers"源代码字符集"设置为UTF-8。语言设置为Russian,国家设置为RUSSIAN FEDERATION

在粘贴到Poedit之前,我确保俄语文本是从utf -8编码的文本文件中复制的。

我错过了什么?

下面是从notepad++复制的messages.po:

msgid ""
msgstr ""
"Project-Id-Version: 'n"
"Report-Msgid-Bugs-To: 'n"
"POT-Creation-Date: 2011-11-16 10:49-0000'n"
"PO-Revision-Date: 2011-11-16 10:49-0000'n"
"Last-Translator: '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:''websites''cthorn.co.uk''live'n"
"X-Poedit-Language: Russian'n"
"X-Poedit-Country: RUSSIAN FEDERATION'n"
"X-Poedit-SourceCharset: utf-8'n"
"X-Poedit-SearchPath-0: .'n"
#: localization/index.php:10
msgid "This is the text to be translated."
msgstr "Это текст для перевода."

啊,对不起-下载文件:

cthorn(点)有限公司(点)英国/定位/地区/ru_RU/LC_MESSAGES/messages.mo英国cthorn(点)有限公司(点)/定位/地区/ru_RU/LC_MESSAGES messages.po

(我只能发布两个链接,因为我是一个n00b)

确保所有内容都是utf-8格式,这样效果会很好。

不同的内容编码总是以在a**

你页面上的俄语文本是ISO-8859-5。问题是它是如何结束的编码:)你能出示你的。po文件吗?

乌利希期刊指南。你文件里的一切看起来都很好。我唯一能想到的就是试试这个:

    setlocale(LC_ALL, $locale.'.utf8');
    bind_textdomain_codeset("messages", 'UTF-8');