M
M
Mister88912015-07-13 12:44:18
Yii
Mister8891, 2015-07-13 12:44:18

How to make database multilingual?

I recently started using Yii2, and the task was to make the site multilingual. I've been struggling with this problem for the third day and I can not solve it. How to display content in the desired language from the database?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
M
Mister8891, 2015-07-13
@Mister8891

I just don't understand the principle. Here I created a database with fields id title_ru title_en text_ru text_en. So? And how do you switch between them?

L
LAV45, 2015-07-23
@LAV45

https://github.com/LAV45/yii2-translated-behavior

N
Nazar Mokrinsky, 2015-07-13
@nazarpc

Add a column with the language in the table, filter by the column when selecting.
Or store the record in one table, and the texts in another with a column in which the language is indicated. That is, there will be one entity, but several language versions.
If you are interested, CleverStyle CMS is out of the box and very easy to use.

D
Dmitry, 2015-07-13
@2fox

i use json + beforeSave / afterFind internal functions
and for mapping https://github.com/codemix/yii2-localeurls

V
Vladimir Golubev, 2015-07-13
@wladyspb

We have a dual system. wherever you want to insert text, a function is called that determines the current language, and searches for the text by the passed key. All short phrases are pulled from a separate file (one file for each language) where key/value pairs are stored. All long phrases (texts) are already taken from the database, where key \ value pairs + the lang parameter are also stored.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question