Could you please help me using Yii::t() ?

Hi,

Could you please help me, why is the translation not working ? Have I did something wrong or missed anything ?

In my config file main.php:



<?php


'sourceLanguage' => 'en', // the language that the application is written in


'language' => 'en', // the language that the user is using and the application should be targeted to

Then in my view formSelectType.php file:

<?php 


echo  Yii::t('formSelectType', 'testMe');


?>


And in my messages/en/formSelectType.php:

<?php


return array(


     'testMe' => 'This is a test'


);

Now, however I still don't see that the language is changing, instead it displays the 'testMe' that I've passed as in Yii::t('formSelectType', 'testMe');

testMe

Please help me to figure this out. Thanks!

Please any clue ?

You should use it this way:

echo Yii::t('formSelectType', 'This is a test'); //this is your sourceLanguage, 'en'

you can translate to german in protected/messages/de/formSelectType.php

return array(


    'This is a Test' => 'Das ist ein Test'


);

This will work.

Hallo, danke fuer Ihre Antwort.

Das waere leider doch die gleiche an was ich schon probiert habe. Nur bei Ihnen, ist das Wort: "testMe" mit dem "This is a test" umgetauscht werden.

Aber ich habe die Loesung gefunden. Was ich getan habe, nur einfach das "sourceLanguage" in config/main.php loeschen, und hat es funktioniert.

Trotz, danke ich Ihnen.

Bis dann!

Quote

You should use it this way:
echo Yii::t('formSelectType', 'This is a test'); //this is your sourceLanguage, 'en'

you can translate to german in protected/messages/de/formSelectType.php

return array(


    'This is a Test' => 'Das ist ein Test'


);

This will work.