any ideas for developing multilingual websites

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
seco
Forum Newbie
Posts: 23
Joined: Tue Jan 08, 2008 10:40 pm

any ideas for developing multilingual websites

Post by seco »

Hi
im asking about good ideas of developing multilingual websites
i can save articles in db and there is a column called lang which has language value and load data based on a url parameter
this is my small idea
any other good ideas ?

the second question what is i have already a one language website and i want to develop it to accept more languages?

thanks in advance.
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Re: any ideas for developing multilingual websites

Post by anjanesh »

You can create a separate table for your language text.

Code: Select all

CREATE TABLE IF NOT EXISTS `language strings` (
  `StringID` bigint(20) NOT NULL auto_increment,
  `English` varchar(255) NOT NULL default '',
  `French` text NOT NULL,
  `Spanish` text NOT NULL,
  `German` text NOT NULL,
  PRIMARY KEY  (`StringID`),
  UNIQUE KEY `English` (`English`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1';
For each block of english text, you can enter its other-language equivalent.
Only problem is, you got to enter the equivalent for all such block, which can be huge if you have a large database of translations. For non-english characters, store their html-entity codes.
seco
Forum Newbie
Posts: 23
Joined: Tue Jan 08, 2008 10:40 pm

Re: any ideas for developing multilingual websites

Post by seco »

do you mean that html entities are less in size that the actual representation that the actual characters of non English text?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: any ideas for developing multilingual websites

Post by Christopher »

I often just create subdirectories for templates for each language like:

Code: Select all

templates/
template/EN/
template/ES/
template/FR/
Then when they pick the language you insert the language code into the path when loading.
(#10850)
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Re: any ideas for developing multilingual websites

Post by anjanesh »

seco wrote:do you mean that html entities are less in size that the actual representation that the actual characters of non English text?
It should be the same in size I guess.
If you can store non-english characters directly, then your mysql-interface supports unicode. Internally, its still stored as html-entity-code.
seco
Forum Newbie
Posts: 23
Joined: Tue Jan 08, 2008 10:40 pm

Re: any ideas for developing multilingual websites

Post by seco »

thanks for reply
arborint says a solution that create templates for each language and then choose the appropriate one
but my content is all dynamic i mean i load the data from db does your way for dynamic contents
would you mind clarify your way

thanks in advance.
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Re: any ideas for developing multilingual websites

Post by anjanesh »

arborint says a solution that create templates for each language and then choose the appropriate one
Its mostly done that way as loading time is minimized.

But if you have article content in a database and want to display a translated version of the article, then one way is to store the translations into the database too.

For smaller strings, you can store its translation into the database too, but your loading time would be much higher as you would end up making many queries to extract the translation text. Using cached results from the db-table is a good idea.
Post Reply