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. Quote Link to comment 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 ?? Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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/'); Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment 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 ! 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.