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

Where is php code written?

519


Whether it is possible to share a single instance of a memcache between multiple php projects?

540


What are regular expressions in programming?

510


What is super () python?

545


What is the difference between characters 23 and x23?

556






What are php parameters?

535


Is php a cms?

541


Explain the difference between session and cookies in php?

518


Is array empty php?

508


How to count all the lines of code in a directory and sub folder?

518


What is the difference between $name and $$name?

529


How can we execute a php script using command line?

528


How be the result set of mysql handled in php?

595


What are psrs? Choose 1 and briefly describe it?

952


Is rent a variable cost?

561