The fastest way to save and retrieve translated text - a database or a flat file?

I am working on updating our site to work in different languages.

My plan is to store paragraphs of text in several languages ​​and give each paragraph an identifier.

Example
id => '1'
brief => 'welcome_paragraph'
ru => "Welcome to our site!" de => 'Willkommen auf unserer Website!'

Requirements

  • quick search
  • edited via CMS anytime
  • easy to add new languages

So what is the best solution to store this in a database table? And if so, which of the following is the best setting for the table:

One table, a column for each language, and a row for each short message:

ID, brief, en, de, es

, , :

ID, brief

ID, language, translation

....

echo $page- > translate ($ language, $brief);

, .... , :

SELECT translation FROM translations 
WHERE language = 'es' AND brief = 'welcome_paragraph'
LIMIT 1

? flatfile? PHP , , ?

$english = array(
'message1' => 'message1',
'message2' => 'message2',
'message3' => 'message3');


$german = array(
'message1' => 'Nachricht1',
'message2' => 'Nachricht2',
'message3' => 'Nachricht3');

Zend Translate page Zend Translate ... , ?

+3
1
+3

Source: https://habr.com/ru/post/1740165/


All Articles