我一直在這裏反彈了幾天,現在沒有任何成功。我只想讓gettext工作。Gettext不工作,沒有錯誤信息,使用PHP 5.3
會發生什麼是字符串,因爲它是寫在php文件打印,而不是翻譯的一個。即如果我做「回聲gettext(」服務「);」然後打印「服務」,而不是瑞典語「Tjänster」。
httpd/error_log中絕對沒有錯誤消息。不是在運行應用程序或(重新)啓動apache時。
使用Centos 6.2和php 5.3。
這是我的目錄結構:
/path/to/locale/sv_SE.utf8/LC_MESSAGES/messages.mo
/path/to/setlocale.php
我messages.po文件:
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-01-18 20:09+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <[email protected]>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: setlocale.php:29
msgid "Service"
msgstr "Tjänst"
#: setlocale.php:30
msgid "Name"
msgstr "Tjänst"
setlocale.php:
<?php
if (!function_exists("gettext"))
{
echo "gettext is not installed";
}
else
{
echo "gettext is supported";
}
echo "Exist?: ".setlocale(LC_MESSAGES, 'sv_SE.utf8')."; //Prints 'sv_SE.utf8, hence it exist in the system.
bindtextdomain('messages', '/var/www/html/smic/modules/core/localization/locale');
textdomain('messages');
bind_textdomain_codeset('messages', 'UTF-8');
echo gettext("Service");
echo _("Name");
?>
由於「支持gettext」被打印,gettext至少在某種程度上工作。
「sv_SE.utf8」還印,因此,它存在於系統中
我以正確的安裝包(好,至少根據已經盡我所能理解我,但當然這裏可能會有一些問題)。 PHP 5.3帶有intl作爲核心的一部分。我沒有設法使用./configure --enable-intl進行編譯。我在嘗試使用時出現錯誤,我想這是因爲它是PHP 5.3的一部分。我對嗎?
我找不到任何intl.so(updatedb完成並搜索它)添加到php.ini文件中,也沒有添加擴展名= intl.so。我也沒有成功,但如果我找不到intl.so,我想這是沒有意義的,增加extension = intl.so?
某些線程提到一些包安裝,我想,還有:
yum install libicu-devel
yum install libicu
將是巨大的,如果有人可以幫助,我看不出如何推進和最帖子/線程正在討論如何在使用PHP 5.2時安裝intl不是其中的一部分。但我甚至不知道問題是否與系統設置或其他相關。
同樣的問題在這裏。什麼樣的圖書館沒有錯誤信息? :( – Manu 2012-08-06 18:05:21
我有一個類似的問題,但我解決了它:http://stackoverflow.com/questions/11828542/nothing-gets-translated-using-gettext/11835265#11835265 – Manu 2012-08-06 20:16:56