Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/291.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP`gettext`在Ubuntu中不工作_Php_Internationalization_Gettext_Php Gettext - Fatal编程技术网

PHP`gettext`在Ubuntu中不工作

PHP`gettext`在Ubuntu中不工作,php,internationalization,gettext,php-gettext,Php,Internationalization,Gettext,Php Gettext,我正在尝试使用PHP的get text为我的网站添加多语言支持。到目前为止还没有成功,我也不知道为什么 在我的i18n.php文件中,我有以下内容: <?php $locale = 'pt_PT.utf8'; $locale_dir = './locale'; $domain = 'messages'; setlocale(LC_ALL, $locale); putenv("LANG=$locale"); putenv("LANGUAGE=$locale"); bindtextdoma

我正在尝试使用PHP的
get text
为我的网站添加多语言支持。到目前为止还没有成功,我也不知道为什么

在我的
i18n.php
文件中,我有以下内容:

<?php

$locale = 'pt_PT.utf8';
$locale_dir = './locale';
$domain = 'messages';

setlocale(LC_ALL, $locale);
putenv("LANG=$locale");
putenv("LANGUAGE=$locale");
bindtextdomain($domain, $locale_dir);
bind_textdomain_codeset($domain, 'UTF-8');
textdomain($domain);

?>
然后生成
.mo
文件:

msgfmt -o ./locale/pt_PT.utf8/LC_MESSAGES/messages.mo ./locale/pt_PT.utf8/LC_MESSAGES/messages.po
php似乎要求在linux系统中安装语言环境,因此我选择了
locale-a

C
C.UTF-8
de_AT.utf8
...
en_AG
...
es_AR.utf8
...
POSIX
pt_BR.utf8
pt_PT.utf8
...

i18n.php
是我第一次包含在
index.php
文件中,但没有显示任何消息。你知道我遗漏了什么吗?

你想如何在
index.php
中输出文本?用电子邮件?老实说,我不记得了,这个问题很老了
C
C.UTF-8
de_AT.utf8
...
en_AG
...
es_AR.utf8
...
POSIX
pt_BR.utf8
pt_PT.utf8
...