Need help for bilingual 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
asu23
Forum Newbie
Posts: 1
Joined: Wed Nov 25, 2009 5:45 am

Need help for bilingual website

Post by asu23 »

Hi,

My name is Asutosh. We have develop a website in PHP and mySQL, out goal was make this website in bilingual. After we developed, now we are facing to make it bilingual. We want to add two language apart from English,

1. Arabic
2. french.

Can anyone suggest me, how I can make this changes.

Please send or reply me on my mail ID.

Regards
Asutosh roy
asutosh_rou@aol.in
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: Need help for bilingual website

Post by papa »

It's usually a very big task so impossible to answer with the information given.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Need help for bilingual website

Post by pickle »

To determine what language to use, I believe the browser passes the preferred language when it requests a page. You can use that to determine which language to display. To allow the user to choose a different language, have a simple form somewhere on your website. Whether you get the language from the form or the browser, you should set the language to use as a session variable, so it persists & you don't need to re-determine the language on every page load.

For actually showing your site in multiple languages, you use an include file with the strings translated into different languages, like so:

Language file

Code: Select all

 
<?php
$lang['welcome'] = array(
  'en'=>'Welcome',
  'fr'=>'Bienvenue',
  'ar'=>'Ya hala');
?>
Some file on your site

Code: Select all

<?php  echo $lang['welcome'][$_SESSION['lang']; ?>
Assuming $_SESSION['lang'] has been set to the language the user wants, either 'en', 'fr', or 'ar'.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply