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

Link to comment
Share on other sites

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
Share on other sites

@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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.