سؤال
لدي ملف dk.po
و dk.mo
في مجلد Lang في 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
وأعتقد (غير متأكد) أن عليك استخدام نفس المسارات!
نصائح أخرى
هذا يعمل بالنسبة لي هو اسمي اسمه
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.
لا تنتمي إلى StackOverflow