MySQL structure for translations

In accordance with this approach, the language already translated is used in the first table . If the user does not need a translation, he will not fight with them. Just plug in the main table so that everything ...

PRODUCT TABLE (InnoDB):

 Obj_id(PK)             name                    desc
 ---------      -------------------     ------------------
     1          Million Dollar Baby    Short description is...
     2          Music Album            Another explanation...

TRANSFER TABLE (InnoDB)

 trans_id (PK)    Obj_id (FK)   lang      field              trans
--------------   -----------   ------    --------    ---------------------
      22              1          TR        name       Milyonluk Bebek
      23              1          BA        name       Djevojka od milijun...
      24              1          TR        desc       Kisa açiklama burada
      25              1          BA        desc       Kratki opis je ovdje
      26              2          BA        name       Glazba albuma

But the problem occurs when the administrator wants to change the default language. I have two options for solving this problem:

  • The administrator must decide default_lang at the beginning of the project, and if he still wants to change default_lang in the future, the program will say Go to hell.

  • As a first solution, the administrator must first resolve default_lang, but the system will be able to transfer the new default_lang data from the translation table to the main table (I do not).

, .

DEFAULT_LANG ( , - )?

+5
4

, . , , .

TRANSLATIONS_TR
TRANSLATIONS_EN
TRANSLATIONS_FR
TRANSLATIONS_BR

, .

+4

, ( ):

(1) (N) ( , , , 'es', 'en')

[ Product ]—(1)—————(N)-[ProductName]
|    id   |             | name      |
                        | language  |

, Product-Language N: M:

[ Product ]-(N)—————————(M)-[Language]
|   id    |        |        |iso_code|
             (translation)  | name   |


[   Product   ]<————[ProdTranslation]———>[language]
|    id       |     | name          |    |iso_code|
|default name?|                          | name   |--- (name of language: "English")

"" (). :

[   Product   ]
|    id       |-(1)————(1)-[ EnglishProduct ]
|default name?|            | name (in eng.) |
|             |
|             |-(1)——(1)-[FrenchProduct]
|             |          | name(in fr.)|

a) 3 ( ), b) . , , /, ..

[ Product ]
| id      |
| name_en |
| name_fr |
| name_de |

, , , , .

+1

gettext , : gettext , - .

You should use gettext or the equivalent for fixtures such as error messages, a button label, or a page title where there is a small list of items that change infrequently.

A multilingual database is designed for large volumes of content that may or may not change frequently, for example, the names of hundreds of thousands of books and films or descriptions of tenders.

0
source

All Articles