Yii i18N Language

Hi Everyone!

I use the i18N language library in my Yii project.

I made 3 language file over the messages folder fr/fr.php,en/en.php,de/de.php

If i select a language for example “fr” , how i can get the content of fr.php’s array.

$selectedLanguage = get the selected language array’s content.

sorry for my language. :)

Hi Ervin,

By using Yii::t() and you can find documentation about it in


You can also search in the wiki, you’ll find what you want i think.

good luck with next.

Hi there

I don’t say what you’ve done is wrong, but one standard way is to have the same file name under you ‘fr’, ‘en’ and ‘de’ folders, let’s say it’s ‘translations’, ok?

Then you simply use

echo Yii::t('translations', Yii::app()->language);

Also, if you want an easy and efficient way to handle your languages in your urls and user sessions, you can see this wiki