MySQL / PHP / Angular 5 - How to store car models translation

152
March 27, 2018, at 02:40 AM

I'm building a new website about a cars where backend will be written in PHP with MySQL database and frotnend will be Angular 5.

About a project:

Because I'm targeting on multi national audience so I'm planning to translate website to multiple languages but I'm facing a problem with translation of something like car models.

Each car manufacturer has multiple models, and he is adding a new one time to time.

What is the issue:

Because, models are changing (not extremely often but still fast enough) I was thinking that it doesn't make sense to keep translation hardcoded somewhere in my FE applcation or use i18n for this kind of things (Let me know if i'm wrong).

What was my original idea

Because models will be always dynamically fetched from server based on manufacturer selection my another idea was to keep things stored in database like schema below

Models table
    --------------------------------------------------
    | id  | manufacturerId | languageId |    name    |
    --------------------------------------------------
    | 22 |       1         |     4      |  5er Reihe |
    --------------------------------------------------
    | 23 |       3         |     5      |  5 Series  |
    --------------------------------------------------

and always sent language settings as one of params. Unfortunately this solution wouuld not work. Atleast not correctly, because when I will add new article I would have to specify modelId and in this case e.g. BMW 5 Series would have multiple rows in table for multiple translation.

Later on I was thinking that this idea can go a bit more further and I could add some aditional table which will map model tranbslation to original modelId e.g.

Models table
 -----------------------
 | id  | manufacturerId |
 -----------------------
 | 22 |       1         |
 -----------------------
 | 23 |       3         |
 -----------------------
Model Translation
 --------------------------------------
 | modelId  | languageId |    name    |
 --------------------------------------
 |    22    |     4      |  5er Reihe |
 --------------------------------------
 |    23    |     5      |  5 Series  |
 --------------------------------------

Conclusion:

I probablly find some idea how this things could work but I consider it slightly dirty and not nice. Is there any other way I can not see or did I miss something while thinking about this issue?

Rent Charter Buses Company
READ ALSO
Avoid app downtime while fixing issues behind MySQL timeout

Avoid app downtime while fixing issues behind MySQL timeout

Many different factors can cause timeout while querying MySQL databasesI know how to troubleshoot and fix the issues behind that

187
Spring JPA Foreign keys are not being created in mysql

Spring JPA Foreign keys are not being created in mysql

I am new to Spring and HibernateWhen I create a table the are no foreign keys being created

184
Removing BOM from a UTF-8 MySQL/MariaDB search

Removing BOM from a UTF-8 MySQL/MariaDB search

I'm importing UTF-8 CSV data to MariaDB/MySQLSince I'm using a shared server, my hosting company doesn't let me use LOAD DATA INFILE, so I need to do it the old fashioned way

168