site in multiple language

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View


here is vishal.

i am creating a site which will have one option for change language.
once user selects the language i am storing his reply in session
variable. then i want to display the site in his selected language. so
can anyone give me idea that how can i achieve this????

whether i should use database for storing words in different languages
or i should use file for each language.

is there any other better way to solve this problem???????

thxs for your reply in advance.

Re: site in multiple language

vishal wrote:

Quoted text here. Click to load it

Hi vishal,

The technical side isn't complicated, the syntax/language part is hard.
What you need to create is a database that stores all pieces of text for
each language and retrieve the needed once on each request.

Something like this:

[postgresql style]

// contains possible languages
CREATE TABLE tbllanguage(
  languageid SERIAL PRIMARY KEY,
  language TEXT

// contains names for pieces of text
// websitetextname here is just a name for yourself to identify the
// piece of text, it is not used to display.
CREATE TABLE tblwebsitetextnames(
  websitetextnamesid SERIAL PRIMARY KEY,
  websitetextname TEXT

// contains the content for peices of text in a langauge
CREATE TABLE tblwebsitetextlanguage(
  websitetextlanguageid SERIAL PRIMARY KEY,
  languageid integer REFERENCES tbllanguage(languageid),
  websitetextnamesid integer REFERENCES    
  thetext TEXT

Suppose you store the languageid in a session.
On a page you need 3 pieces of text (indentified by websitetextsid), you can
look them up in tblwebsitetextlanguage.

If you use languages with difficult characters, be sure to look into all the
encodingtypes. (I cannot help there)

A few tips:
1: It makes sense to retrieve all the needed peices of text needed on a page
in 1 query for speed at the top of the page.
Remember that retrieving 20 rows in 1 query is much faster than 20 seperate

2: You can handle images in the same way. Just let thetext in
tblwebsitetextlanguage contain an image, including the tag: <img

3: I am sure more advanched content management systems have similar
functionality, so if you doubt you can roll this one, have a look at them.

This is just a basic setup.
Hope it helps.

Erwin Moller

Re: site in multiple language

thxs for your valuable information

Re: site in multiple language


Quoted text here. Click to load it

gettext might be an option as well.


Re: site in multiple language

Quoted text here. Click to load it

It all depends on the languages you're supporting. It's one thing to handle
English, French, and German, it's quite another to handle English, Hindi,
and Urdu.

Site Timeline