homepage Welcome to WebmasterWorld Guest from 54.198.42.105
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Multi Language Sites
Best way to do it.
ryan_b83




msg:3524458
 9:01 pm on Dec 10, 2007 (gmt 0)

Hello I am planning to build a PHP/MySQL based product/category site. It needs to be able to display both English and French. The way I would structure the database would be:

titleEnglish
titleFrench

descriptionEnglish
descriptionFrench

And so forth... which isn't too bad, however what about for the static content on all the pages? I was thinking just making it session based and every peice of content would need an if statment.... so for example....

if($_SESSION['lang'] == "english"){
?>
english content here...
<?
}
else{
?>
french content here...
<?
}

This seems like alot of work for just static content but it seems like the only way... or does anyone else have suggestions?

Thanks,
Ryan

 

LifeinAsia




msg:3524501
 10:02 pm on Dec 10, 2007 (gmt 0)

You can put the static text in text files and just read the appropriate file based on the language.

gergoe




msg:3524587
 11:22 pm on Dec 10, 2007 (gmt 0)

What I have used to do is to store every piece of text in database (even if only two languages are needed), and there's an another table, which maps the texts to pages, and each time a page is loaded the mapped texts are automatically loaded into a variable (well, I used the oop approach, so it is not a simple variable), and when a text has to be displayed, a function is called, which returns the the text (using the selected language) by using a codename (defined for each text). Although not sure my description is clear, that's the way I found for myself.

Quite some other products chosen to make include files which are defining hundreds of constants (for each language), and then it uses these constants for displaying texts.

Whatever you choose, don't forget to check out the printf() [php.net] series of functions as they come very handy when dealing with multilingual content.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved