Yii multilanguagelanguage

Hello!

I have some problem with multilanguage…

My Model is /experiments/first

i tried to install messages/en/yii.php and messages/de/yii.php in there.

config (main.php):


'language'=>'de',

'languages'=>array('de','en'),

'messagePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'messages',

'fileTypes'=>array('php'),

'translator'=>'t', 

yii.php looks like that:


<?php

return array (

  'test' => 'test Deutsch',

);



just to test this, I put in controller


echo Yii::t('yii','test');

the output should be 'test Deutsch, but ist ‘test’. Do anybody know why? I’m looking forward to any hint…

bauchinj

Hi bauchinj,

For a translation to take place you need to set the sourceLanguage property in main.config.




'sourceLanguage'=>'en',

'language'=>'de',

'languages'=>array('de','en'),

'messagePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'messages',

'fileTypes'=>array('php'),

'translator'=>'t', 



If the target language is en, no translation will take place. If the target language is de, translation will occur. If you want a translation to occur every time, you can set the sourceLanguage to 00.

Check out this great wiki for more info Translations.

Also, I don’t think using ‘yii’ as your translation category in Yii::t(‘yii’, ‘test’) is a good idea, I think this is a reserved word for the translation method.