Gjert
Gjert

Reputation: 1067

How to store multi-lingual website information in database?

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

Upvotes: 2

Views: 151

Answers (1)

Dave
Dave

Reputation: 434

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.

Upvotes: 1

Related Questions