Answer the question
In order to leave comments, you need to log in
What are the normal methods for creating a multilingual site?
For myself, I saw two options for creating a language switch:
1) I create 2 files consisting of such data
rus
priv = Hello World
site = My site
eng
priv = Hello World
site = my site
name | rus | eng
priv | Hello world | Hello world
site | My site | my site
Answer the question
In order to leave comments, you need to log in
In most cases, the first option is better.
1. Maintain language files - easier than sql (simpler and freer syntax)
2. Easier to expand in case of additional languages - the main thing is to think over the naming of language files in advance so that switching to the language automatically loads the necessary file, such as include lang_$lang.php
Store everything in the database makes sense only because of organizational / security decisions (for example, it is safer to give access to the database than to the file system, and then store everything in the database)
first generally accepted
en={}
en['hw'] = 'Hello, Microsoft Word!'
en['title'] = 'This is my multilangual site'
ru={}
ru['hw'] = 'Привет, Ворд'
#templates/ru.html
title = ru['title'] if 'title' in ru else en['title']
There are several standards for localization (i10n) and internationalization (i18n).
A pretty good analysis of different rules is made here
guides.rubyonrails.org/i18n.html
https://www.npmjs.com/package/i18n
https://docs.angularjs.org/guide/i18n
php.net/intl
Everywhere is somewhat different approach, but in general it all comes down to creating a map and conventions.
Personally, I would store data for translation in 2 places.
The first place is the fastest storage method for your PL/framework. This option is for production and load.
The second place is the base, for editing. After editing, automatic generation of files for the first option.
The translation mechanism should be implemented in such a way that if an unfamiliar translation is encountered in the development / testing mode, it is saved to the database. In the future, this is brought into normal form by a professional translator, for which an appropriate interface must be created.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question