簡體   English   中英

php gettext 不適用於 Windows Server 2008、PHP 5.5

[英]php gettext not working on Windows Server 2008, PHP 5.5

讓 gettext 在 Windows Server 2008 R2、PHP 5.5 上工作時遇到問題

我在我的 php 腳本中執行以下操作:

$language = 'NB';
putenv("LANG=".$language);
putenv("LC_ALL=".$language); 
setlocale(LC_ALL, $language);
$domain = 'messages';
bindtextdomain($domain, 'C:/path_to_translations/translations'); 
textdomain($domain);

我的翻譯文件位於以下目錄中:

C:/path_to_translations/translations/NB/LC_MESSAGES/messages.po C:/path_to_translations/translations/NB/LC_MESSAGES/messages.mo

這在我的帶有 php 5.3 的 Windows 7 機器上運行良好

我猜 NB 在 Windows 上並不是一個真正有效的語言環境名稱,但 setlocale(LC_ALL, 'NB') 仍然返回 'NB' 而不是 FALSE。 盡管如此,為了查看這是否與問題有關,我嘗試設置 $language = 'norwegian',在這種情況下 setlocale(LC_ALL, 'norwegian') 返回 'Norwegian_Norway.1252',並嘗試將路徑名更改為C:/path_to_translations/translations/norwegian/LC_MESSAGES/messages.mo 和 C:/path_to_translations/translations/Norwegian_Norway.1252/LC_MESSAGES/messages.mo 以及更改 .po 和 .mo 文件上的編碼來自'UTF-8 ' 到 'Windows 1252'。 但是,我無法在 Windows Server 2008 R2、PHP 5.5 機器上進行翻譯。

更新。 從未讓 gettext 與 php 5.5 一起使用,但發現其他用戶也有類似問題( https://bugs.php.net/bug.php?id=66265

嘗試安裝 php 5.4,現在一切正常。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM