Answer the question
In order to leave comments, you need to log in
Architectural question: multilingual site?
Good afternoon everyone.
There was a question about the creation of a multilingual site.
There will be various news, articles and other sections on the site, while there is no guarantee that the article from the Russian version will be translated into English.
It will be opened through the subfolder domen.ru/(en/ru)/
How best to implement the database and content administration?
Answer the question
In order to leave comments, you need to log in
The easiest thing in this situation, in my opinion, is to simply duplicate the fields that need to be translated, something like:
id: integer, required
title_ru: string, required
body_ru: text, required
title_en: string
body_en: text
and change depending on the url field names to select. The scheme is simple, easy to implement, there are practically no overheads, but the main drawback is that it is very inflexible.
Well, if the content is different, then maybe two different sites?
As a rule, the English version should contain English-language pages, texts, news, etc. In Russian, of course, Russian. Devman correctly advised, add a field responsible for the language to the usual list of fields in the database (as if it were a site with a monolingual architecture). And then everything is simple, in the admin panel you make a filter switch - which will show records with either one field value or another. In the frontend, we also simply use this filter. It is flexible enough, there can be at least as many languages, in fact, you can even dynamically add them from the admin panel) The main thing is that the database will not swell with redundant fields.
Just recently, I implemented just such a module by adding fields to existing tables for localization:
name_locale
content_locale, etc.
In the data editing card in the admin panel, the “Language” tab was added, where the fields for editing localization data were placed. Localization added to pages, news, test blocks. I also added a separate design template for the second language to the connection settings, which turns on when you change the language.
you can see what happened.
The best model for data translation is presented, for example, in the globalize plugin for AR. github.com/svenfuchs/globalize3 - if interested.
A variant with a separate table for all translations is a translation of strings, for example. But you have to bother with caching, since this business will make a lot of requests.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question