tags:

views:

228

answers:

3

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

how can i use this file? i have try all, but i can't relly get it to work.

pls help me.

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

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

// Choose domain
textdomain("dk");

Tanks a lot.

+1  A: 

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
hmmm, i not relly understand :/ i have file into this folder /var/www/domain.com/lang/dk/dk.mo can you make a sample out of this info?
NeoNmaN
im sorry for my variables .. substitute $locale with "lang/dk" and App::$root with "/var/www/domain.com/"
luca
A: 

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
if i have a big project, can i out zend translate into this? or will it be hard?
NeoNmaN
Just grab the entire Zend library and include just the Zend Translate class and you should be good.
meder
Okay, and all my "gettext()" function still work? :)
NeoNmaN
You will not need to use `gettext` php function, because Zend provides its own entire implementation of gettext. One thing though, your host *must* be using PHP5 or Zend won't work.
meder
+1  A: 

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