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
What is the difference between require and include in php?
Explain what is meant by pear in php?
which will print out the php call stack?
List the different types of print functions available in php?
Explain mail function in PHP with syntax?
What is session expiry?
What is namespace and use in php?
Why do we use csrf token?
How to access a specific character in a string?
Is laravel an oop?
How to create a web form?
Explain whether it is possible to share a single instance of a memcache between multiple php projects?
Why print_r is used in php?
What is fetch array in php?
What is the use of htmlspecialchars in php?