我在夹郎文件dk.podk.mo在我WEBDIR。

我如何使用这个文件?我已经尝试了所有,但我无法得到它的工作。

// Lang
putenv('LC_ALL=dk');
setlocale(LC_ALL, 'dk');

// Specify location of translation tables
bindtextdomain("dk", ROOT .'lang');

// Choose domain
textdomain("dk");
有帮助吗?

解决方案

我这个已经工作:

setlocale(LC_ALL, 'ar_LY.utf8');
bindtextdomain("trans", $_SERVER["DOCUMENT_ROOT"].'/trans/locale');
textdomain("trans"); 

语言文件路径:

/var/www/trans/locale/ar_LY/LC_MESSAGES/trans.mo

和我认为(不知道),你必须使用相同的路径!

其他提示

这对我的作品 我的文件被命名为messages.mo

static function initialize_i18n() {
    $locale=App::$locale;        
    $locales_root = App::$root."locale";
    putenv('LANG='.$locale);
    putenv('LANGUAGE='.$locale);
    putenv('LC_ALL='.$locale);    
    putenv('LC_MESSAGES='.$locale); 
    setlocale(LC_ALL, $locale.".utf-8");   
    $domains = glob($locales_root.'/'.$locale.'/LC_MESSAGES/messages-*.mo');
    $current = basename($domains[0],'.mo');
    $timestamp = preg_replace('{messages-}i','',$current);
    bindtextdomain("messages",$locales_root);
    textdomain("messages");
}    

我会认真建议使用Zend_Translate此,你可以碰到很多不一致的与各种类型的系统locales

文档: http://framework.zend.com/manual /en/zend.translate.using.html

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top