使用gettext的setlocale问题

时间:2016-02-12 04:34:09

标签: php gettext setlocale

在我的生产服务器(CentOS)中,setlocale似乎需要以下格式:en_US

哪个不适合我,因为我有248个国家和66种语言 - 访问者可以选择任何语言的国家/地区。

是否可以只是en

有趣的是,在我的本地服务器(MacOSX)上它可以与en一起正常工作。

<?php
putenv('LANG=' . $_SESSION['locate']['language']['iso'] . '_' . $_SESSION['locate']['country']['iso']); // I want to use only en, not en_US
setlocale(LC_ALL, $_SESSION['locate']['language']['iso'] . '_' . $_SESSION['locate']['country']['iso']); // I want to use only en, not en_US

bindtextdomain('messages', dirname(__FILE__) . '/locate');

textdomain('messages');

echo gettext('This is a text string!');
?>

0 个答案:

没有答案
相关问题