简体   繁体   English

Gettext用英语翻译,但不翻译法语

[英]Gettext translating in English but not in French

so the issue is the following. 因此问题如下。 I am converting a site from a content array for each language to a gettext site with 2 additional to the original languages. 我正在将网站从每种语言的内容数组转换为具有2种原始语言的gettext网站。

So my base language is es_MX and I have en_US and fr_FR translations. 所以我的基本语言是es_MX,我有en_US和fr_FR翻译。

I use the following parameters in .htaccess to pass info on the locale: 我在.htaccess中使用以下参数来传递语言环境信息:

RewriteRule     ^/?$            index.php?es=./&en=./en/&fr=./fr/&locale=es_MX [L]
RewriteRule     ^en/?$          index.php?es=./&en=./en/&fr=./fr/&locale=en_US [L]
RewriteRule     ^fr/?$          index.php?es=./&en=./en/&fr=./fr/&locale=fr_FR [L]

So, when I check the $_GET parameters everything is received correctly. 因此,当我检查$ _GET参数时,一切都会正确接收。

Case 1: Default es_MX 情况1:默认es_MX

Array
(
    [es] => ./
    [en] => ./en/
    [fr] => ./fr/
    [locale] => es_MX
)

Case 2: en_US 情况2:en_US

Array
(
    [es] => ./
    [en] => ./en/
    [fr] => ./fr/
    [locale] => en_US
)

Case 3: fr_FR 情况3:fr_FR

Array
(
    [es] => ./
    [en] => ./en/
    [fr] => ./fr/
    [locale] => fr_FR
)

So, after that what I do in order to have several language variables for use at say social network plugins or attributes, I have the following conditions: 因此,在此之后,为了使多个语言变量可用于社交网络插件或属性,我需要满足以下条件:

if(!$_GET["locale"] || $_GET["locale"] == "es_MX") {
    $locale = "es_MX";
    $locale_general = "es_LA";
    $lang = "es";
    $isolang = "es-419";
    $htlang = "es-MX";
} else if($_GET["locale"] == "en_US") {
    $locale = "en_US";
    $locale_general = "en_US";
    $lang = "en";
    $isolang = "en";
    $htlang = "en-US";
} else if($_GET["locale"] == "fr_FR") {
    $locale = "fr";
    $locale_general = "fr_FR";
    $lang = "fr";
    $isolang = "fr";
    $htlang = "fr-FR";
}

After that I initialize the locale using: 之后,我使用以下命令初始化语言环境:

putenv("LC_ALL=".$locale.".utf8");
setlocale(LC_ALL, $locale.".utf8");
bindtextdomain("hacienda", "./locale");
bind_textdomain_codeset("hacienda", "UTF-8");
textdomain("hacienda");

My locales are located at: - English (./locale/en_US/LC_MESSAGES/hacienda.mo) - French (./locale/fr_FR/LC_MESSAGES/hacienda.mo) 我的语言环境位于:-英语(./locale/en_US/LC_MESSAGES/hacienda.mo)-法语(./locale/fr_FR/LC_MESSAGES/hacienda.mo)

I ran exec("locale -a",$output) and the site shows a bunch of locales among which are several fr_FR entries including fr_FR.utf8. 我运行了exec("locale -a",$output) ,该站点显示了一堆语言环境,其中包括fr_FR.utf8等几个fr_FR条目。

The generated html is: 生成的html是:

<html class="no-js" lang="fr" xml:lang="fr" itemscope itemtype="http://schema.org/Hotel"> <!--<![endif]-->
<head>
    <meta charset="utf-8">
...

I tried renaming the locale file also created a new one but it doesn't seem to get the french translations. 我尝试重命名语言环境文件也创建了一个新文件,但是它似乎没有得到法语翻译。 Any idea what might be causing that? 知道是什么原因造成的吗?

That's very embarrasing, but I missed to add _FR to $locale = "fr"; 这非常令人尴尬,但是我错过了在$locale = "fr";添加_FR $locale = "fr"; now that I fixed it to $locale = "fr_FR"; 现在,我将其固定为$locale = "fr_FR"; it's working. 它正在工作。 Sorry for the waste of time. 很抱歉浪费时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM