How can I create a multilanguage active record in the Yii framework? So in my CRUD -> create / update, I can enter e.g. the title in english and dutch

有帮助吗?

解决方案

Take a look at internationalization:

http://www.yiiframework.com/doc/guide/1.1/en/topics.i18n

By setting the language parameter in the config file you specify what language to use. Echo your content with

Yii::t('langfile','message to translate');

For translations from the database look at:

http://www.yiiframework.com/doc/api/1.1/CDbMessageSource

Once you have everything in place. You can create CRUD operations for the translations just like you could for other any other database table.

Tutorials/More info:

http://www.pintarprogramming.com/23/Yii-internationalization

http://learnyii.blogspot.nl/2010/12/yii-setting-up-internationalization.html

其他提示

In the end I used this class: http://www.yiiframework.com/extension/multilingual-behavior/

And the CDbMessageSource solution

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top