I am attempting to introduce multi-language support into the back end of an application, and trying to figure out a strategy to efficiently implement this into the current schema.
I currently have multiple tables, all of which include standard english values.
My idea is in each table w/ english values, include a foreign key that relates to a single "Language" and multiple "Language values" in the table holding translations
So for ex.
Table-1
Value | Lang_ID
"This is a sentence" | 1
"This is also a sentence" | 2
"Translate this" | 3
Table-2
Value | Lang_ID
"This is a sentence from another table" | 4
"This table is different from table-1" | 5
Language-Table
Lang_ID | Lang_Code | Value
1 | "ZHO" | "这是一句话"
1 | "SPA" | "esta es una frase"
2 | "FRA" | "c'est aussi une phrase"
3 | "SPA" | "traduce esto"
4 | "FRA" | "ceci est une phrase d'un autre tableau"
....
My thinking is you would then just need to query Language-Table by WHERE Lang_ID=? AND Lang_Code=? to get the translation for that specific value.
I'm wondering a couple things
1) Is this a good practice?
2) How do I generate foreign keys that don't exist yet over multiple tables and keep each one unique (so as not to have two translations of different text values fall under the same Lang_ID)