S
S
Sergey2014-06-20 15:05:47
Yii
Sergey, 2014-06-20 15:05:47

How to organize content translation in YII2?

We have two options:
1) Store `content_ru`,`content_en` in the model, get Yii::$app->language and somehow get
get->'content_'.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

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
Petr Zhuchkov, 2014-06-20
@TsarS

habrahabr.ru/post/226931 Today's article

M
Mikhail Osher, 2014-06-20
@miraage

Counterquestion. Why not use native gettext?

A
Alexz29, 2016-05-25
@Alexz29

Add to model

/**
* format return fields
*
* return array
*/
public function fields()
{
return [
'news_id',
'news_title'=>function () {
return Yii::t('app', $this->news_tilte'),
},
...
];
}

It's in theory

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question