moho
(Goldendegree)
April 27, 2009, 8:41pm
1
I am working the i18n for a project that I am working on. I still cannot figure out how i18n works for a multilanguage setup. I plan to do sth similar to the Doc here with a slight difference.
Anybody got a tutorial or example on how to set this up?
Thanks,
ouhman
(Ouhman)
April 28, 2009, 9:43am
2
Hi moho,
Yii provides two types for i18n, database or file. (see http://www.yiiframew…ide/topics.i18n )
As I am using the translation with file I will explain you how to do it.
Add one private variable in the controler as follow :
And in the init method in the SiteController :
So I use en as default and save it in a cookie.
I've created several folders in /protected/messages/
Like /protected/messages/en/ (for english) /protected/messages/fr/ (for french)…
After that Create a file (e.g. :blog.php) wich will contain translations in this directory.
The file (blog.php e.g.) in en directoy will have the following content :
And in /protected/messages/fr directory:
After that just call :
Yii::t('blog','home');
Hope it helps
moho
(Goldendegree)
April 28, 2009, 11:36am
3
Great. Thanks. Just what I need.
henqi
(Hengkhee)
May 6, 2009, 7:05am
4
Thanks, this help me a lots… save much of my time…