How will you create a bi-lingual site (multiple languages) ?

Answer Posted / ahmad pujianto

use session...it work better. Check my sample
<?php
session_start();
session_register("language");

if(empty($_SESSION['language']))
{
$_SESSION['language']='en';
}

if(isset($_GET[lang])){
if($_GET[lang]=='id' or $_GET[lang]=='en'){
$_SESSION['language']=$_GET[lang];

echo '<meta http-equiv="refresh" content="0;
url=?language='.$_GET[lang].'">';
}else{
echo '<meta http-equiv="refresh" content="0;
url=?error=Unavailable_Language_Option">';
}
}

?>
Make this script on a single file, include the file in each
pages, then simply add link that give value $_GET[lang].
Each time there is $_GET[lang], this script will change the
$_session['language'].

Then in each part that need to be bilingual, check for
$_SESSION['language'].

Thats all

Is This Answer Correct ?    14 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why do we need abstract class in php?

508


Why and where do we use htaccess?

532


What is meant by public, private, protected, static and final scopes?

534


Explain the visibility of the property or method?

573


Explain how to submit form without a submit button.

545






How does session work in php?

532


What is difference between mysql_connect and mysqli_connect?

507


Why do we use sessions in php?

532


Explain the difference between unlink() and unset()?

539


Does facebook use php framework?

558


How to check a key exist in an array?

577


What is the use of mysql_real_escape_string() function?

519


Write a query to find the 2nd highest salary of an employee from the employee table?

648


How do you measure variables?

524


How you can update memcached when you make changes to php?

618