Internationalization problem

Hi,

I am trying to make multi-language site. I’m using yiic to generate translation files.

In view:




<?php Yii::app()->setLanguage("lt_lt"); ?>

<?=Yii::t('test', 'blah')?>



protected/config/translate.php




return array(

    'sourcePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..',  //root dir of all source

    'messagePath' => '/var/www/yii/project/protected/messages',  //root dir of message translations

    'languages'  => array('lt_lt', 'en_us', "es_es", "ru_ru", "de_de"),  //array of lang codes to translate to, e.g. es_mx

    'fileTypes' => array('php','js',), //array of extensions no dot all others excluded

    'exclude' => array('.svn',),  //list of paths or files to exclude

    'translator' => 'Yii::t',  //this is the default but lets be complete

);



Yiic successfully creates translation files under protected/messages/ID/test.php




return array (

  'blah' => 'blah in lithuanian',

);



Also mentioned language in main.php config:




return array(

...

        'language' => 'en_us',

...

);



But when visiting site, it always shows me just blah, not translated. What I am missing? o_0

Your example should work. Do you use caching?

/Tommy

No, I’m trying l18n on freshly created app with default stuff. Yii version [size=2]1.1.6 (latest). This is weird…[/size]

It’s essential that you don’t set sourceLanguage to ‘lt_lt’, though.

/Tommy

The main config is incorrect, you should set:


return array(

...

        'sourceLanguage' => 'en_us',

...

);



This will say that the app is written in english.

Now setting


<?php Yii::app()->setLanguage("lt_lt"); ?>

Will say that we want to translate from english to lt.

Thank you for this tip. Tried this now, but still nothing. Maybe something is wrong in translate files?

protected/messages/lt_lt/test.php





return array (

  'blah' => 'blah in lithuanian',

);



protected/messages/en_us/test.php





return array (

  'blah' => 'blah in english',

);



And finally, the problem was permissions (weird, because "read" was set to all).

Thank you guys for trying to help me.

… just a note, maybe it’s an explanation: “r” is not sufficient for directories, the also need the “x” (executable) flag to be set, before you can access (read) them.