hocn
(Hocnv91)
April 24, 2014, 2:27am
1
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.
Thanks
jkofsky
(Jkofsky)
April 24, 2014, 2:43am
2
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.
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.
hocn
(Hocnv91)
April 24, 2014, 2:49am
3
Hi @jkofsky
Thank for reading and reply to me.
jkofsky:
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.
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?
Thanks
jkofsky
(Jkofsky)
April 24, 2014, 3:03am
4
A quick look in the CLocale file shows
locale->getLocaleIDs();
locale->getLocaleDisplayName();
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".
hocn
(Hocnv91)
April 24, 2014, 3:12am
5
jkofsky:
A quick look in the CLocale file shows
locale->getLocaleIDs();
locale->getLocaleDisplayName();
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?
Thanks
jkofsky
(Jkofsky)
April 24, 2014, 3:18am
6
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?
Thanks
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