Jump to content

[SOLVED] design question for translation table


anatak

Recommended Posts

I want to make a site available in multiple languages.

I want to store all the text of the site in a mysql database.

example of text would be

"welcome to our site"

 

I thought about 2 systems.

1 table with a column for the ID of the message and a column for every language.

 

the advantage is that it is rather fast and easy to select messages in more than one language as every message has a single ID (primary key)

The big disadavantage is  that if I need to add a language to the site I have to add a column in this table.

 

the other system I was thinking was to create a table with a column for the messageID a column for the languageID and a column for the message.

The primary key is a combination of messageID and languageID.

the advantage is that adding a language is easy but selecting the messages will (I think) take more time because not all the messages are always translated in all the languages.

to select a message I will always have to select the default language and the user desired language. if the message is not available in the user desired language it has to be displayed in the default language.

 

my question is

what would you do ?

Link to comment
Share on other sites

Hi,

I normally use a single table with column for each table.

The fields are defined with _en, _es etc.

Adding a new language is just a matter of adding a new column with the same format.  I actually have a script that does this automatically - ie when I want to add a new language it loops through the tables, finds the fields that end with "_en" (I only use this system for language fields) and adds a new one with the new ending.  So for example to add german to the web, if it finds a  field such as "title_en" it will add "title_de".

 

Chris

Link to comment
Share on other sites

Hey Chris,

 

The way you described it is the way I did it in another site and I think it was the best way to do it.

I was just looking if somebody else knew of a different way.

I ll guess I ll do it the same way again. That makes it also easier in the copy paste department :)

 

to fenway

this was a design question maybe I posted it in the wrong forum ?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.