Current location: Hot Scripts Forums » Programming Languages » PHP » Select language


Select language

Reply
  #1 (permalink)  
Old 12-30-05, 08:55 PM
zitwep zitwep is offline
Wannabe Coder
 
Join Date: Aug 2005
Posts: 108
Thanks: 0
Thanked 0 Times in 0 Posts
Select language

I was wondering how I could make users of a website change the language of the site. If for example I would have 2 language files:

lang_eng.php
lang_de.php

with all the language variables in there. I was thinking about having a drop down box on top of the site where users could change the language of the site. How would I make my site chose the language file corresponding to the language which is selected by the user?
Could you please tell me how I could achieve this, thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 12-30-05, 09:05 PM
Christian's Avatar
Christian Christian is offline
Community VIP
 
Join Date: Mar 2005
Location: ProgrammingTalk
Posts: 2,449
Thanks: 0
Thanked 6 Times in 5 Posts
this tutorial from NeverMind's site might help.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 12-30-05, 09:26 PM
zitwep zitwep is offline
Wannabe Coder
 
Join Date: Aug 2005
Posts: 108
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks, it brought me a step further.

But I still don't get how to make a drop down menu for users to be able to change the language.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 01-01-06, 01:48 PM
eq1987 eq1987 is offline
Wannabe Coder
 
Join Date: Dec 2003
Posts: 216
Thanks: 0
Thanked 0 Times in 0 Posts
zit, make the dropdown form, action="changeLang.php"

next, you will need to either use a cookie/session to store their language choice, or put it in the URL

PHP Code:

/* changeLang.php */

$_SESSION['Language'] = $_POST['Language'];
// setcookie("Language", $_POST['Language'], time() + 3600);
// URL method will require you to add the QUERY STRING to all pages. might get tough
if($Language == 'English') {
  include 
'English.php';

PHP Code:

/* English.php */

$Lang = array(
 
"SiteName" => "PT",
 
"Greeting" => "Hello"
); 
PHP Code:

/* Other.php */

$Lang = array(
 
"SiteName" => "Lhsd",
 
"Greeting" => "Sjhsdf"
); 
PHP Code:

/* SomePage.php */

echo $Lang['SiteName']; // if they included English.php, this variable will be set as PT, if they included Other.php, it will be set as Lhsd 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Combining select statements jack_mcs PHP 0 08-12-05 02:25 PM
Multiple language support in PHP - best method? harlock PHP 2 08-11-05 04:19 AM
Multiple Select phppick JavaScript 3 04-11-05 01:09 AM
Select List insert into DB The Omega JavaScript 1 01-12-05 01:51 PM
i have 3 select box this is urgent traceMe JavaScript 0 12-02-03 02:24 AM


All times are GMT -5. The time now is 08:24 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.