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
How can you get web browser’s details using PHP?
In PHP, fgets() is used to read a file one line at a time. State Whether True or False?
How does php work with apache?
How to remove duplicate values from a PHP Array?
How to redirect https to http url through .htaccess?
What is the difference between unset and unlink?
What are string functions?
Can you pass an array into a function?
Do you know what is the difference between the include() and require() functions?
What is the default time in seconds for which session data is considered valid?
What is use of count() function in php?
What does $globals means?
What are psrs? Choose 1 and briefly describe it?
Can php run without apache?
How to fix "headers already sent" error in php