2014-10-01 62 views
0

我试图让gettext在本地服务器上工作,但它不工作。它不给我任何错误,它只是用西班牙语返回我的字符串,而不是将它翻译成英文。Gettext不工作

这是的index.php

<html> 
<?php 
$locale = "en_US"; 
putenv("LC_ALL=$locale"); 
setlocale(LC_ALL, $locale); 
bindtextdomain("messages", "./locale"); 
bind_textdomain_codeset("messages", 'UTF-8'); 
textdomain("messages"); 
?> 
<?= _("Volver al Panel") ?> 
</htlm> 

这是messages.po,位于区域设置/ EN_US/LC_MESSAGES/

# SOME DESCRIPTIVE TITLE. 
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER 
# This file is distributed under the same license as the PACKAGE package. 
# FIRST AUTHOR <[email protected]>, YEAR. 
# 
msgid "" 
msgstr "" 
"Project-Id-Version: PACKAGE VERSION\n" 
"Report-Msgid-Bugs-To: \n" 
"POT-Creation-Date: 2014-10-01 11:31-0300\n" 
"PO-Revision-Date: 2014-10-01 11:38-0300\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" 
"X-Generator: Poedit 1.5.4\n" 

#: index.php:10 
msgid "Volver al Panel" 
msgstr "Back to Panel" 

当然,我还创建“命令的messages.mo msgfmt messages.po“没有问题。

事情是它应该返回“回到面板”,而不是“回到面板”,我错了吗?

回答

0

我想出了什么问题,并可以解决它。

我使用了命令语言环境-a,并且意识到我没有安装名为en_US的语言环境,但是我确实有一个en_US.utf8语言环境,所以我将它们切换并且工作。