Proposed Internationalization Method in MySQL?

I have a website in Cohan and I plan to use it in several languages.
Now I know the path with the i18n folder and inside each language folder
there is some kind of strings.php file ..
But I want a dynamic path (in the database) so that I can change the values ​​whenever I want. through the website.

Is there any general table layout commonly used for multi-language content?

+3
source share
1 answer

Well, you can probably emulate a “resource” file in your database,

You may have a table that acts as a directory for your rows, with two columns, for example

Lang_Constants
ID, Constant_Name
1, HELLO_STRING

:

Languages
ID, Name
1, English
2, Spanish

:

ID, Language, Constant, Value
1,   1, 1, "Hello world!"
10,  2, 1, "Hola mundo!"

:

SELECT Value from Lang_Constant_values where 
  Language = (Select ID from Languages where Name = 'English')
and
  Constant = (Select ID from Lang_Constants where Constant_Name = 'HELLO_STRING')
+2

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


All Articles