Answer the question
In order to leave comments, you need to log in
How to store data in a database for a multilingual site?
Good afternoon guys, please tell me the following situation!
There is a site on the node, at the given address site.com - English version, on ru.site.com - Russian
version , all in two languages)
The question is, how can I organize the database so that I can search in both Russian and English?
I have a huge gag in this, that is, either I create 2 databases and then how should I access each of them when searching, because the pages of any version of the site need the ability to search in 2 languages, how to properly organize such storage and search further in 2 languages on any version of the site?
Answer the question
In order to leave comments, you need to log in
You can make a filter :
filters: {
shorten: (val, words = 2) => val.split(' ').slice(0, words).join(' '),
},
<div>{{ text | shorten }}</div>
<div>{{ text | shorten(5) }}</div>
I will write how I do it.
Columns with names are simply duplicated in width in this way (example: on the title field): title[ru], title[en], etc. and just when requesting select, I put the desired language from the content display language variable and that's it.
Thus, you need to change the code minimally, and the main structure of the database is not necessary at all: just add fields with additional. languages in tables.
It is better not to modify or overflow the database with translated data. It's easier to have some kind of separate dictionary where to store the translated information and pull the values from there.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question