Architecture for a multilingual website

LightningRider

Senior member
Feb 16, 2007
558
0
0
Hey guys

I'm going to be developing a website that is going to be in two languages. I think that having two files for each page, one for each language is kind of hard to maintain.

I'm wondering if the best way to implement multiple languages is not to either store the content in each language and then retrieve the correct label depending on which language the user has selected.

What do you guys think? I'm pretty sure that this would be the best as far as maintainability goes, but what is the most performing way to accomplish this? Storing text in a MySQL database? Or would it be better to have XML files or something else, etc?

Thanks
 

MrChad

Lifer
Aug 22, 2001
13,507
3
81
What language are you using for the website?

One way to do it in Java is to use ResourceBundles (http://java.sun.com/developer/...Intl/ResourceBundles/) and create text files with all of your application text. Each language gets its own text file. If done properly, you can add new languages simply by translating the application text and creating a new resource file.

I've seen similar approaches done using databases. Depending on your performance requirements, you may want to cache your system text in memory so that you're not constantly reading from text files and or databases.
 

JasonCoder

Golden Member
Feb 23, 2005
1,893
1
81
As of 2.0 this is now unbelievably easy in .Net. Make internationalizing a site as easy as skinning.
 

LightningRider

Senior member
Feb 16, 2007
558
0
0
I am going to be using PHP5, MySQL and Apache.

I guess text files would probably be faster than database storage huh.
 

drebo

Diamond Member
Feb 24, 2006
7,034
1
81
It really depends on your site and what kind of content and how much content you are providing.

If all you need is labels (this would include form field labels, buttons, menu items, etc, etc) to be in a different language, then yes, a text file is your best bet, as the overhead of SQL queries would be silly. However, you're probably going to be using some kind of content management in a database for the actual content of the pages. For this, you'd use a hybrid solution, with text files being your labels and the database providing your content.

There really is no wrong way to implement this as long as it works for you and you're satisfied with the result. Me, personally, I would use text files to handle labels and then just duplicate translations in the database for any actual content I had. Really wouldn't be that difficult, honestly.