Jump to content

Bilingual Site Content


Valentin

Recommended Posts

Hey guys, I'm working on my church's website, and it is bilingual. I have a problem with displaying the content. The site is made up by including the content file using PHP. Editing the content is really annoying in multiple files, so I want to be able to show or hide the content in one file based on the 'lang' variable in the address bar. My brother tried doing something with JavaScript or CSS or something, where he collapsed the text, but we kept on running into problems. The content includes text, pictures, and hyperlinks, so I was wondering if anyone would have an idea as to how I can structure the code to work. If anyone can help or give me pointers, then that would be great. Thanks.

Link to comment
Share on other sites

There are several posts here about multilingual sites, the idea is the same. Have a series of content files in PHP that just list out the content in different languages, and include whatever language file you want on any page to show the content for that page. e.g.

<?php$content = array(  'title' => 'Home',  'menu1' => 'Food',  'menu2' => 'Drinks',  'image1' => 'http://domain.com/images/image1_en.jpg');?>

That would be the English file, so you would include that if you want to show English. You can have a Spanish one also:

<?php$content = array(  'title' => '¡A la casa!',  'menu1' => '¡Tengo comidas!',  'menu2' => '¡Estoy borracho!',  'image1' => 'http://domain.com/images/image1_es.jpg');?>

Your pages would just have placeholders for the things that you want to change based on language.

<?phpinclude 'languages/en.php'; // or whatever language?>...<head><title><?php echo $content['title']; ?></title></head><body>...<img src="<?php echo $content['image1']; ?>">

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...