language website with content from database
I'm new to Yii Framework. Trying to build multi-language Yii application. I think it's usefull to provide information about what I did to every Yii starter who wants to build multi-language project. Here's what I did:
Built translation database for common words and navigation items (based on this article)
Now the last thing that I can't figure out is , say we have pages in multiple languages. Each page has title, content in en, ru, it... how to get multilanguage content from database and show right one based on current language?
After some research I found tutorial which shows how to get content from database in YII application. BUt there is nothing about multi-language support.
Thx in advance for wasting your time and trying to help me.
I think the easiest way to do it, is to set a prefix for each table with the language, and make your models take the Yii::app()->language parameter to define your table. Ofcourse only do this for tables containing content to be translated.
A second way would be to load all your content and filter out the content you want in your controller based on the language, but that creates an overhead of data in your controllers.
链接地址: http://www.djcxy.com/p/37498.html上一篇: 关于多结构逻辑的建议
下一篇: 语言网站内容来自数据库