Rommeo Posted October 3, 2009 Share Posted October 3, 2009 I m coding a multi language website. I have two links to change the language ; <a href="http://www.mysite.com/index.php?lang=en">ENGLISH </a> <a href="http://www.mysite.com/index.php?lang=de">German </a> The problem is, when I load the page in any language, let's say english. And when I click to "German" nothing changes ( the page does not load in german language )But when I refresh the page it works, also when I enter the address manually like : http://www.mysite.com/index.php?lang=de it works...But clicking does not change anything. Is there any solution for this problem ? I want to change the language of the webpage when I click to "english" or "german" button. Link to comment https://forums.phpfreaks.com/topic/176405-solved-can-not-change-the-language/ Share on other sites More sharing options...
ProXy_ Posted October 3, 2009 Share Posted October 3, 2009 Can we see your code, this way it will allow us to better understand the situation. As far as i see, it should work correctly, are you using Ajax xmlHttp ?? Link to comment https://forums.phpfreaks.com/topic/176405-solved-can-not-change-the-language/#findComment-929776 Share on other sites More sharing options...
Rommeo Posted October 3, 2009 Author Share Posted October 3, 2009 Can we see your code, this way it will allow us to better understand the situation. As far as i see, it should work correctly, are you using Ajax xmlHttp ?? There is nothing special really <?php $language = $_GET['lang']; if ( $language == "de" ) include "de.php" else include "en.php" ?> I m not using ajax or smth else. This is the code I m using. Maybe I should use something like header-location, but I dont know how. Link to comment https://forums.phpfreaks.com/topic/176405-solved-can-not-change-the-language/#findComment-929779 Share on other sites More sharing options...
ProXy_ Posted October 3, 2009 Share Posted October 3, 2009 Ok, the only next thing i can think of. Make sure your file is .php extension and not .html If your file is a .php and you still have this issue. Can i have the url of this website? so i can see everything in action. Link to comment https://forums.phpfreaks.com/topic/176405-solved-can-not-change-the-language/#findComment-929782 Share on other sites More sharing options...
cags Posted October 3, 2009 Share Posted October 3, 2009 Yes but what code do you have where the user clicks? If it's a standard anchor link (<a href="mysite.com?lang=en" >...</a>) then that should work, otherwise probably not. Link to comment https://forums.phpfreaks.com/topic/176405-solved-can-not-change-the-language/#findComment-929784 Share on other sites More sharing options...
ProXy_ Posted October 3, 2009 Share Posted October 3, 2009 For header you can use the code below: header('Location: http://www.example.com/'); Link to comment https://forums.phpfreaks.com/topic/176405-solved-can-not-change-the-language/#findComment-929787 Share on other sites More sharing options...
Rommeo Posted October 3, 2009 Author Share Posted October 3, 2009 @proxy : When I write the address and load the page like http://www.mysite.com/index.php?lang=en or http://www.mysite.com/index.php?lang=de it works,language is changed. if there was a problem with the extensions then it would not work. @cags : That's the anchor code I m using, I just copied and changed to the mysite stuff. I dont know any other type of anchor tags. And there is just "img src" tags where I m using this tags, nothing special. Link to comment https://forums.phpfreaks.com/topic/176405-solved-can-not-change-the-language/#findComment-929792 Share on other sites More sharing options...
ProXy_ Posted October 3, 2009 Share Posted October 3, 2009 k, then i know this sounds funny but this happends to be ALOT for some reason. Lets give this a quick try. Sometimes for me when you add a Variable for the POST it won't follow through correctly Example you got: <?php $language = $_GET['lang']; if ( $language == "de" ) include "de.php" else include "en.php" ?> try this. just to see... <?php if ( $_GET['lang'] == "de" ) { include "de.php"; } else { include "en.php"; } ?> See if that works for you. It happends to me on a daily basis while dealing with Forms & the post method. Hopefully this helps you - EDIT - i also added brackets to your if statement. give that a try. Link to comment https://forums.phpfreaks.com/topic/176405-solved-can-not-change-the-language/#findComment-929794 Share on other sites More sharing options...
cags Posted October 3, 2009 Share Posted October 3, 2009 Also try changing your links to the shorthand form without the full http://yoursite.com adddress... <a href="?lang=en">English</a> <a href="?lang=ge">German</a> ... see if it makes a difference Link to comment https://forums.phpfreaks.com/topic/176405-solved-can-not-change-the-language/#findComment-929796 Share on other sites More sharing options...
PFMaBiSmAd Posted October 3, 2009 Share Posted October 3, 2009 Try this - http://www.phpfreaks.com/forums/index.php/topic,271402.msg1281020.html#msg1281020 Link to comment https://forums.phpfreaks.com/topic/176405-solved-can-not-change-the-language/#findComment-929805 Share on other sites More sharing options...
Rommeo Posted October 3, 2009 Author Share Posted October 3, 2009 It works now. Thank you all for your help ! Link to comment https://forums.phpfreaks.com/topic/176405-solved-can-not-change-the-language/#findComment-929810 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.