PDA

View Full Version : Multilingual site script problem



Shile
16 Oct 2008, 09:34 AM
I am making multilingual site with this script

<?php
// get informations from url
$lang = @$_GET['lang']; // @ supress errors if is lang definition empty
$page = @$_GET['page']; // @ supress errors if is page definiton empty

if($lang == "ger"){ // include ger container and right page
include("container_ger.php");
switch($page) {
case "1": include("1ger.php"); break;
case "2": include("2ger.php"); break;
case "3": include("3ger.php"); break;
default: include("1ger.php");
}
} else {
include("container_eng.php"); // include eng container and right page
switch($page) {
case "1": include("1eng.php"); break;
case "2": include("2eng.php"); break;
case "3": include("3eng.php"); break;
default: include("1eng.php");
}
}
?>
And I make link with this

<?php
echo "<a href = www.yoursite.com/index.php?lang=ger&page=$page> Germany </a>" ;
?>
or for same language and different page:

PHP Code:
<?php
echo "<a href = www.yoursite.com/index.php?lang=$lang&page=3> Go to page 3</a>" ;
?>
BUT!! The link are generated by ECHO command...I know how to make it an image and text but now I want to make drop drop down menu and I dont know how to make it.How to include echo function in drop down menu??

If you know how or you have different script for changing pages please post..

tnx

maxloaded
20 Oct 2008, 04:30 PM
Create a dropdown list on the html side of mypage.php. It should be something like this:

<form action="mypage.php"
method="post">
<select name="language">
<option value="en">English</option>
<option value="ger">German</option>
<option value="fr">French</option>
</select>
<input type="submit" value="GO" name="submit" />
</form>

Then on the php side,

<?php


// Check if form has been submitted

if(isset($_POST['submit'])) {

//Get the values for selected language

$lang = $_POST['language'];

// If English

if($lang == 'en') {

//Your code for loading the page in english

}

// If German

if($lang == 'ger') {

//Your code for loading the page in german

}

// If French

if($lang == 'fr') {

//Your code for loading page in French

}

}

?>

NOTE: This is a simple code to load different languages on mypage.php that i've written right now. It is not your final code.

Just play around to see if you can get it to work.