Page 1 of 1

How to use multi language support in my website ?

Posted: Thu Mar 04, 2010 8:56 am
by shubhamdas.mca
Hi

I have a website and I willing to make it multi language support.

So regarding this I request kindly sugest me anyone.

Thanks..

Re: How to use multi language support in my website ?

Posted: Thu Mar 04, 2010 9:30 am
by AbraCadaver
There are many ways to do this. For a simple approach, I would store the multi-lingual content in the database with a language identifier:

main table

Code: Select all

id  lang    key         value
1   en      WELCOME     Welcome to my site
2   fr      WELCOME     Bienvenue sur mon site
You can have multiple tables for different content just as you would normally:

articles table

Code: Select all

id  lang    title           article
1   en      My Article      This is my article content.
1   fr      Mon article     Ceci est le contenu de mon article.
Then you have easy ways to get the correct data after you know the user's language:

Code: Select all

SELECT value FROM main WHERE key='WELCOME' AND lang='en'
 
SELECT * FROM articles WHERE id=1 AND lang='fr'
This makes it easy to add a form where different editors can translate stories, messages, etc.

Re: How to use multi language support in my website ?

Posted: Thu Mar 04, 2010 4:05 pm
by greyhoundcode
AbraCadaver wrote:articles table

Code: Select all

 
id  title  article
1   en     My Article   This is my article content.
2   fr     Mon article  Ceci est le contenu de mon article.
Then you have easy ways to get the correct data after you know the user's language:

Code: Select all

SELECT value FROM main WHERE key='WELCOME' AND lang='en'
 
SELECT * FROM articles [color=#BF0000]WHERE id=1 AND lang='fr'[/color]
No entry matches that condition?