I have been struggling with this problem for over a week and am not much nearer a solution. I am trying to create a multi language site that only requires the content to be added as simple text or html files although php files can be included. I have a page that detects the language used on the users browser:
The $content variables can contain php includes contained in the individual language_sets language.php files:
In the code above, I want to allow the user to select a different language if required. I found a snippet on this site which will do this but have come unstuck. What I want is for the include/langselect.php file above to allow the user to redirect to the index file of their choice. In this instance for the english page: /language_sets/en/language.php. So far in the include/langselect.php file, I have the code:
I am not sure I need all of this and also don't know how to redirect the user to the right page with the above script. Obviously, I could have written individual pages for the original redirect but that was far too easy and I wouldn't have learned nearly as much as I have this week!
I hope someone can help before I go completely mad!
Simon
Code:
<?
class object {};
$config = new object;
$config->dir = "/home/path/public_html/language2/lang_sets/";
if (! isset($lang)) {
$lang = "pt";
$lang = "en";
$lang = "lv";
}
else if ($lang == "pt-br" ) { $SESSION["lang"] = "pt"; }
else if ($lang == "en" ) { $SESSION["lang"] = "en"; }
else if ($lang == "lv" ) { $SESSION["lang"] = "lv"; }
else { $SESSION["lang"] = "en"; }
$config->global = $config->dir.$lang."/language.php";
include ($config->global);
?>
<html>
<head>
<title>webwhiz language2</title></head>
<body>
<?=$content4?>
<?=$content1?>
<?=$content2?>
</body>
</html>
Code:
<?
$content1 = include_once("../include/langselect.php");
$content2 = include_once("../include/contactform.php");
$content4 = include_once("../include/footer.php");
?>
Code:
<?php
$language = $_GET["language"];
?>
<select onchange="window.location='select.php?language='+this.value">
<?php
$language = array(
"",
"English",
"Portuguese",
"Latvian",
"Spanish");
for ($i = 1; $i <= 4; $i++)
{
print "<option value=$i>$language[$i]</option>";
print "<h3>Language is : $language[$i]</h3>";
}
?>
</select>
I hope someone can help before I go completely mad!
Simon
Comment