Search
Left Quote    You have to THINK anyway, so why not think BIG?
- Donald Trump    
Right Quote
 
[login] | [Register]
Forum Index » PHP and mySQL » Viewing Topic and Replies
Post Reply


        Viewing Topic: [Help] Multi-language script
  This user is offline  Genius
  Subject: "[Help] Multi-language script" Posted: @ 7:48 pm on Jan 13 2009   

Member #: 582
Rank: User - (77)
Since: 02/18/08
Posts: 76
From: kmmk

I wanted to have multi language on my site. So I created a folder 'languages' and put en.php uz.php and ru.php with translations. To find out the language of the user, i just use this code.


Code:
// Get user language
$lang = $_GET['lang'];

switch($lang){

case 'en':
include 'languages/en.p hp';
break;
case 'ru':
include 'languages/ru.p hp';
break;
case 'uz':
include 'languages/uz.p hp';
break;
default:
include 'languages/en.p hp';

}



When I include lang in the url like, index.php?lang= uz I get all kind of letters. It doesn't work. But when I don't set the language, the default language works fine. Even if I change the default language to uz. Weird problem... Please help.

Edited at 07:53:23 pm on 01/13/09


    Viewed: 9,465 Times | Reply to This | To top
  This user is offline  David1159
  Subject: "re: [Help] Multi-language script" Posted: @ 8:38 am on Jan 16 2009    

Member #: 526
Rank: User - (81)
Since: 12/27/07
Posts: 81
From: usa

That is weird, lol in the end it will problem be something simple, it usually is.

Some ideas:
1. try to echo everywhere to debug the problem
2. instead of switch, try a form of if, else if, else

Honestly I do not know, with what you provided, it looks fine.




Coding is simply CST... Combining $hit Together. We make different $hit to run in unison correctly.

    Viewed: 9,440 Times | Reply to This | To top
  This user is offline  Genius
  Subject: "re: [Help] Multi-language script" Posted: @ 3:56 pm on Jan 17 2009    

Member #: 582
Rank: User - (77)
Since: 02/18/08
Posts: 76
From: kmmk

This is really annoying me. I tried if/else, same error. You can test it here: English Language and Default Language


Code:

// Get user language
$lang = $_GET['lang'] ;

if (isset($lang)) {

if ($lang == 'en') {
include 'languages/en. php';
} else if ($lang == 'ru') {
include 'languages/ru. php';
} else if ($lang == 'uz') {
include 'languages/uz. php';
}

} else {
include 'languages/uz. php';
}



Edited at 05:04:54 pm on 01/17/09


    Viewed: 9,421 Times | Reply to This | To top
  This user is offline  David1159
  Subject: "re: [Help] Multi-language script" Posted: @ 3:27 am on Jan 18 2009    

Member #: 526
Rank: User - (81)
Since: 12/27/07
Posts: 81
From: usa

Are you including the languages first before the header and navigation bar?




Coding is simply CST... Combining $hit Together. We make different $hit to run in unison correctly.

    Viewed: 9,407 Times | Reply to This | To top
  This user is offline  Genius
  Subject: "re: [Help] Multi-language script" Posted: @ 4:00 am on Jan 18 2009    

Member #: 582
Rank: User - (77)
Since: 02/18/08
Posts: 76
From: kmmk

Ahhh, that might fix it. I'm just including it from my functions file. Lemme test it real quick.

EDIT #1: Server having issues... Error 500.
EDIT #2: Nope, same problem.



Edited at 04:17:52 am on 01/18/09


    Viewed: 9,404 Times | Reply to This | To top
  This user is offline  David1159
  Subject: "re: [Help] Multi-language script" Posted: @ 4:23 am on Jan 18 2009    

Member #: 526
Rank: User - (81)
Since: 12/27/07
Posts: 81
From: usa

darn I thought that might do it, because when I read the PageSource, your <title>Uz Playlist - Q</title> is also using the $lang, I figured it was your variables where being declared after you tried displaying them.





Coding is simply CST... Combining $hit Together. We make different $hit to run in unison correctly.

    Viewed: 9,399 Times | Reply to This | To top
  This user is offline  Genius
  Subject: "re: [Help] Multi-language script" Posted: @ 5:10 am on Jan 18 2009    

Member #: 582
Rank: User - (77)
Since: 02/18/08
Posts: 76
From: kmmk

WOOOT! I fix it. Got help from my web hosting forum.

This was the fix:


Code:

// Get user language
switch($_GET[' lang']){

case 'en':
include 'languages/en. php';
break;
case 'ru':
include 'languages/ru. php';
break;
case 'uz':
include 'languages/uz. php';
break;
default:
include 'languages/en. php';

}




    Viewed: 9,395 Times | Reply to This | To top
Viewing Page: 1 of 1


1 |

You must be logged in to post on the forums. Login or Register








"AllSyntax.com" Copyright © 2002-2017; All rights lefted, all lefts righted.
Privacy Policy  |  Internet Rank