PHP`gettext`在Ubuntu中不工作
我正在尝试使用PHP的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
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
...