2

I'm currently creating a multi-lingual website, and I have different types of words that are being translated all across the website. However, whats the best practice when it comes to storing this in the database? This is what I currently do:

I have the language Norwegian and English.

My database looks like this:

Language select

Whenever I add a new language it get added into the languages table like this:

Languages table

At the same time a new table will be created with looking like this language_en. Using the value in language_val.

Later on I use URL routing to retrieve en, no or whatever language and fetch the website information from the correct table.

My question is, should I rather have only 1 table and use the language_id in this one? or is it perfectly fine to split up languages into multiple tables?

Each language table would look just like this: language table

3
  • Java would handle this as locale specific resource bundles. Commented Feb 16, 2016 at 14:51
  • @duffymo What about PHP? Commented Feb 16, 2016 at 14:52
  • Don't know; I don't write PHP. Did you tag your question? Sorry I see that you did now. I missed it. Commented Feb 16, 2016 at 14:56

1 Answer 1

1

With Silverlight (and later with PHP) I've done this by putting the language's in the same table, this worked fine and was user friendly (easy to edit). Only when retrieving data you should off course only select the language you need.

Sign up to request clarification or add additional context in comments.

2 Comments

Is this faster than using separate tables? let's say I have 10 languages, each language has 1000 things to translate?
You should go for as few as possible tables in this case (normalization, en.wikipedia.org/wiki/Database_normalization) this will improve insight and makes your code more manageable aswell.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.