how to add multi language facility in a website?

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
eshban
Forum Contributor
Posts: 184
Joined: Mon Sep 05, 2005 1:38 am

how to add multi language facility in a website?

Post by eshban »

Hi,

I am working on a custom CMS based website. I need to add a multi language facility in this website. Means the same website will be available in these languages i.e. English, German, Swedish, Arabic, French, Dutch. I do not want to make 6 different websites for each language.

What are the best techniques to implement this task. I am using PHP with Mysql.


Looking forward for your replies.

Thanks
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: how to add multi language facility in a website?

Post by pickle »

Make 6 copies of the website content. Make a `en_content`, `de_content`, `fr_content`, etc (or whatever your tables are called). When the user accesses your page, determine what language they want, then pull your content from the appropriate tables.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
rhecker
Forum Contributor
Posts: 178
Joined: Fri Jul 11, 2008 5:49 pm

Re: how to add multi language facility in a website?

Post by rhecker »

The way I have done it is to use sessions to pass the language variable from page to page. So once the visitor selects a language, the variable $language is set to something like _ger for German. Then this drives whic content is delivered to the pages. Each row of the table in the database contains separate columns for each language, like so title_eng title_ger. If the sessions variable is set to _ger, then title_ger gets called, and so forth.

I created a cms backend so the translators could directly edit the page content for the language(s) they were responsible for, showing the English on one panel and the other language in a parallel panel.
Post Reply