S
S
slip312014-05-06 15:08:34
Yii
slip31, 2014-05-06 15:08:34

Yii and content translation

Good afternoon. So how is it correct to work with translations in YII?
I have some widget hanging in the header (en | ru | de ), the user clicks and we change the 'language' to ru_RU, for example. i18n is triggered - after switching to different pages, the message is processed, everything that is in Yii::t() is translated - everything is clear with this.
What to do with articles (if the translation is stored in the database)? Somehow make it clear to modules/controllers that now it is necessary to take content from this field of the base (content_ru) , and not from this one (content_en)?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
H
homyden, 2014-05-07
@slip31

https://github.com/mikehaertl/translatable behavior for translating models. There and about the base is described. The point is to store the essence and separately its translation.

S
Sergey, 2014-05-06
Protko @Fesor

the locale chosen is available to you, and how you build the architecture of the base is up to you.
Regarding the division into databases by language, this is not a very convenient option. At a minimum, there will be problems with data migration and deployment. And yes, it's just not kosher.

S
slip31, 2014-05-06
@slip31

Well, I mean check in each controller "if ru, then content_ru"? Perhaps there are more civilized ways? (well, as I understand it, you can, of course, predefine the Controller yourself, so as not to write in each one)

S
Sergey, 2014-06-19
@TsarS

Anyway, back to the question. We have two options:
1) Store `content_ru`,`content_en` in the model, get Yii::$app->language and somehow get
get->'name_'.Yii::$app->language (By the way, this is it possible to do it?)
2) Store `id`, and store a separate table `id`,`ru`,`en`, well, it's somehow like in Yii:t only with the base
What to choose after all. SEO doesn't matter

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question