A
A
Alexander Koshelev2019-12-16 23:50:14
Vue.js
Alexander Koshelev, 2019-12-16 23:50:14

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

4 answer(s)
0
0xD34F, 2019-02-01
@asferot

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>

X
xmoonlight, 2019-12-17
@xmoonlight

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.

V
Vlad Poltorakov, 2019-12-17
@itxor

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 question

Ask a Question

731 491 924 answers to any question