Get All Langguages From I18N Yii

Hi guys,

I have problem with multi languages.

I want admin can add any languages to my system.

Therefore I need get all country and region code languages.

That means I will display a dropdown list. It has all name languages. When I select any languages. it will auto generate region code.

Ex: I selected English, It will auto generate region code is en.

Please help me resolve this problem.


the dropDownList data would be array(‘en’=>‘English’,‘es’=>‘Spanish’, etc.) You maybe able to look in the translation files for the actual ‘name’ of the language. There maybe a function in Yii::app()->locale the can get a list of available translations.

There many tutorials about i18n in Yii. You could also look at the Yii translation files for ideas.

Hi @jkofsky

Thank for reading and reply to me.

I was tried $languages = Yii::app()->locale->_data; to get array. But because variable $_data is private.

Therefore I can’t get.

Do you have any solution for this case?


A quick look in the CLocale file shows



and a number of others. You need to look through the code. I would the API docs would also have information on using i18n. I have numerous links when searching "Yii using i18n".

Yes. I know, I see all function from Clocale class. But all it only get infomation of languages current in system.

Only $data return array consider all languages and region code for each languages.

Current problem is I can’t get $_data because it’s private variable.

Do you have way to get it?


No, Sorry. I haven’t gotten into i18n yet.

maybe: there’s a php function to list all the dirs in a dir. possible you could loop through them and see what you have available. I believe the translations go in the messages or system director under protected.

Other than that I’m out of ideas :(