What is the standard approach to multiple language apps regarding blocks of static text. I am familiar with Yii and I have read what is available here. Messages, labels, etc. i am fine with.
What i am still confused on though is how to render, let’s say a view, that has 6-7 lines or a paragraph of text, such as a faq’s page, a change password page that has instructions on how to create a strong password, etc… This is not something i will fetch using yii::t() would it? or…
would i create a separate file with the translated text like:
if language is English, render: view_en.php
if language is French, render: view_fr.php. and so on
I don’t think there’s a standard approach, everything depends on your installation.
For such texts I usually support different languages in database. There’re different approaches on how to build such db scheme. If you need to translate only one table, as a good start you may use this structure:
id -- lang -- title -- content. pk(id, lang)
. As an additional plus - having such texts stored in db it’s simple to organize backend for them to edit. You’ll need to use constants or something similar in order to use variables in texts, by replacing constants with variables.
As you mentioned, you may also create static translated files, requesting them depends on your current language, e.g.
$this->render('text_'.Yii::app()->language)
. The plus - it is easy to send variables to these pages.
Or store such translations in a separate messages file, calling it then via
Yii::t('page', 'faq');
well, I don’t think it’s very handy, especially if texts are huge, but still you may use it. It is easy to pass variables to such translations too.
One more variant - is to use CDbMessage source, you may base your code on this wiki
I am looking the appropriate method into implement Internationalization in my site.
At first, I studied to do it from messages (as covered in "Agile Web Application Development with Yii1.1" book and a lot of links in yiiframework) with CPhpMessageSource and CGettextMessageSource. But this methods are to translate few text contents (Thinking just that´d be better use it for: error messages, menus, …)
And in my case, the text contents to translate is huge (i.e. whole pages) and the implementation as of messages is complicated. Because to that one should create a "hard-code" arrays, any inappropriate thruth!
So after seeing your message, I am glad to know that is possible to handle the Internationalization since database. Unfortunately, I didn´t find anything. And that’s why I would like to ask that you explain me how do it:
How do you recover database values?
What files and How would I have to set these, to show the language in the view?