Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Php Language files - Help!
Old 12-02-2007, 03:44 PM Php Language files - Help!
coldturkey's Avatar
Extreme Talker

Posts: 211
Name: Rachel
Location: Spain
Trades: 3
I am doing a web site - with two language files English (en) and Spanish (es) This is my code:
PHP Code:
<?
$lang 
$HTTP_GET_VARS["lang"];
if (
$lang == "en") {
include (
"./lang/en.php");
}
if (
$lang == "es") {
include (
"./lang/es.php");
}
if (!
$lang) {
include (
"./lang/en.php");
}
?>
My problem is when I click on a new link in the page the selected language is not used - it always goes back to the default english.

So do I need a bit of code at the end of each link on the page to say 'if lang has been selected - stay with selected lang' If thats the case what would the code be?
Or is there something else Im missing?


Please help

__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

coldturkey is offline
Reply With Quote
View Public Profile Visit coldturkey's homepage!
 
 
Register now for full access!
Old 12-02-2007, 05:26 PM Re: Php Language files - Help!
Stieffers's Avatar
Novice Talker

Posts: 7
Name: Taylor S
Trades: 0
You'll have to include that bit of code on every page. Turn it into a function or include it in a class and just check at the beginning of every page before the header is draw.
Stieffers is offline
Reply With Quote
View Public Profile
 
Old 12-02-2007, 06:30 PM Re: Php Language files - Help!
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
I would use a switch construct because if the user's browser language is not used in your site, you can set english as the default.

PHP Code:
<?php
  
  
switch ($lang strtolower($_GET['lang']))
  {
    case 
'es':
      include(
'./lang/es.php');
      break;
    default:
      include(
'./lang/en.php');
      break;
  }
  
?>
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Php Language files - Help!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.56112 seconds with 12 queries