Jump to content

[SOLVED] Can not change the language ?


Rommeo

Recommended Posts

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

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.

@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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.