Database – What’s a recommended way to design a db schema for multi-language website

databasedatabase-designlanguagesrelational-database

I'm building a website where I plan to support multiple languages. Not only via UI, but via the content too.

I have several tables where I have text columns such as "title", "name", "description", "body" and so on. What's the best way to do so? Will I have to create an additional table for each one where I have text data I want to translate? For instance:

articles(id)
articles_content(article_id, title, description, body, language_id)


comments(id)
comments_content(comment_id, body, language_id)

And thus for each table I want to translate.

Any downsides of this solution?

Is there a better and yet simpler way?

Best Answer

Create each "table" as a base table (with the non-translatable elements) and a translation table. The language table will contain the primary key of the base table and the language ID. You can then create a view layer which joins the two together for a particular language (and which the UI will drive off of). This scenario avoids the duplicate maintenance of the non-translatable elements.

Related Topic