scar5308 Posted October 23, 2006 Share Posted October 23, 2006 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; index.php:[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]The page; language_sets/en/language.php, then includes the appropriate language specific content for my language files.[code]<?$content1 = include_once("../include/langselect.php");$content2 = include_once("../include/contactform.php");$content4 = include_once("../include/footer.php");?>[/code]I then want the option to allow the visitor to select a different language to the one detected. For this I am trying to use this snippet I found. The included file above langselect.php contains the following code:[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>[/code]This provides a dropdown box to select a language. I am new to php and can't quite see how to make the above script redirect the user to a language specific page; in this case www.site.co.uk/language/index_en.php if English is selected from the dropdown.Any help would be gratefully received!Simon Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.