2

I have a file dk.po and dk.mo in folder lang in my webdir.

How can I use this file? I have tried all, but I can not get it to work.

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

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

// Choose domain
textdomain("dk");
hakre
  • 193,403
  • 52
  • 435
  • 836
ParisNakitaKejser
  • 12,112
  • 9
  • 46
  • 66

3 Answers3

5

I am working with this already:

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

the language file path:

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

and I think (not sure) that you have to use the same paths!

wesamly
  • 1,484
  • 1
  • 16
  • 23
2

this works for me my file is named 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");
}    
Luca Rocchi
  • 6,272
  • 1
  • 23
  • 23
-1

I would seriously recommend using Zend_Translate for this as you can run into a lot of inconsistencies with locales on various types of systems.

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

meder omuraliev
  • 183,342
  • 71
  • 393
  • 434