E
E
EvGenius Karlonius2017-02-18 05:06:15
Internationalization and localization
EvGenius Karlonius, 2017-02-18 05:06:15

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

Depending on the chosen language, I download the file into an array and substitute the contents of the priv and the site in the right places.
2) create a view base:
name | rus | eng
priv | Hello world | Hello world
site | My site | my site

Depending on the chosen language, I download it into an array and substitute the contents of the priv and the site in the right places.
maybe there are better options? Or which method is more efficient?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
Saboteur, 2017-02-18
@BloodKarl

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)

D
Dimonchik, 2017-02-18
@dimonchik2013

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']

the editor has the same feature - you can immediately see the state of translation into a specific language
. a) do not include unnecessary; b) languages ​​are not only words, but also formatting (estimate the length of German words), and store the parameters of divs and so on in the same way

P
Philipp, 2017-02-19
@zoonman

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.

D
d-stream, 2017-02-18
@d-stream

Then the second loop will start:
"there are 3 users on the site" <> "there are 5 users on the site"
versus
"online 5 users" == "online 3 users"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question