asgsoft Posted April 16, 2006 Share Posted April 16, 2006 I have a script and I want to add languages to it. The way I am going to do it is to use the GET method from the url. Defult language is english so if the url is page.php then it will be english, if the page is page.php?lang=fr then it will be french.I started to do it like this but for some reason $lang is set to 1 rather than the language initials.Look a this:[code]<?php$lang = $_GET['lang'];if($lang == "fr" || $lang == "FR"){include "fr.tpl";$lang = "fr";}else{include "en.tpl";$lang = "en";}?>[/code]Another thing.If I want to get a variable from the tpl file how will i do that?At the moment I have :[code]echo "".$lang."_".tnos." $num_rows";[/code]to say the number of rows in the chosen language but it doesn't say anything.Where have I gone wrong? Quote Link to comment Share on other sites More sharing options...
Honoré Posted April 16, 2006 Share Posted April 16, 2006 [!--quoteo(post=365266:date=Apr 16 2006, 12:26 PM:name=asgsoft)--][div class=\'quotetop\']QUOTE(asgsoft @ Apr 16 2006, 12:26 PM) [snapback]365266[/snapback][/div][div class=\'quotemain\'][!--quotec--]At the moment I have :[code]echo "".$lang."_".tnos." $num_rows";[/code][/quote]What is tnos? Is it a variable? Should it be $tnos? Quote Link to comment Share on other sites More sharing options...
asgsoft Posted April 16, 2006 Author Share Posted April 16, 2006 in the english tpl files I have a variable called en_tnos and in french tpl file i have fr_tnos Quote Link to comment Share on other sites More sharing options...
Honoré Posted April 16, 2006 Share Posted April 16, 2006 [!--quoteo(post=365266:date=Apr 16 2006, 12:26 PM:name=asgsoft)--][div class=\'quotetop\']QUOTE(asgsoft @ Apr 16 2006, 12:26 PM) [snapback]365266[/snapback][/div][div class=\'quotemain\'][!--quotec--]I have a script and I want to add languages to it. The way I am going to do it is to use the GET method from the url. Defult language is english so if the url is page.php then it will be english, if the page is page.php?lang=fr then it will be french.I started to do it like this but for some reason $lang is set to 1 rather than the language initials.[/quote]If you call [a href=\"http://page.php?lang=fr\" target=\"_blank\"]http://page.php?lang=fr[/a]and page.php has the following code:[code]<?phpecho $_GET['lang'];?>[/code]What is then the result shown in your browser?[!--quoteo(post=365268:date=Apr 16 2006, 12:43 PM:name=asgsoft)--][div class=\'quotetop\']QUOTE(asgsoft @ Apr 16 2006, 12:43 PM) [snapback]365268[/snapback][/div][div class=\'quotemain\'][!--quotec--]in the english tpl files I have a variable called en_tnos and in french tpl file i have fr_tnos[/quote]As only one file will be included (fr.tpl or en.tpl) you could probably name your variable $tnos in both files and use[code]echo $lang."_"."$tnos $numrows";[/code] Quote Link to comment Share on other sites More sharing options...
asgsoft Posted April 16, 2006 Author Share Posted April 16, 2006 [!--quoteo(post=365269:date=Apr 16 2006, 05:49 AM:name=Honoré)--][div class=\'quotetop\']QUOTE(Honoré @ Apr 16 2006, 05:49 AM) [snapback]365269[/snapback][/div][div class=\'quotemain\'][!--quotec--]If you call [a href=\"http://page.php?lang=fr\" target=\"_blank\"]http://page.php?lang=fr[/a]and page.php has the following code:[code]<?phpecho $_GET['lang'];?>[/code]What is then the result shown in your browser?[/quote]It echos nothingWill it matter if these urls are re-written by a .htaccess file?for example show.php?id=3 is re-written to be some-text-3.php where 3 is the id of the file[!--quoteo(post=365269:date=Apr 16 2006, 05:49 AM:name=Honoré)--][div class=\'quotetop\']QUOTE(Honoré @ Apr 16 2006, 05:49 AM) [snapback]365269[/snapback][/div][div class=\'quotemain\'][!--quotec--]As only one file will be included (fr.tpl or en.tpl) you could probably name your variable $tnos in both files and use[code]echo $lang."_"."$tnos $numrows";[/code][/quote]Good idea I will use it and try it as soon as the above works. Quote Link to comment Share on other sites More sharing options...
Honoré Posted April 16, 2006 Share Posted April 16, 2006 [!--quoteo(post=365270:date=Apr 16 2006, 01:01 PM:name=asgsoft)--][div class=\'quotetop\']QUOTE(asgsoft @ Apr 16 2006, 01:01 PM) [snapback]365270[/snapback][/div][div class=\'quotemain\'][!--quotec--]Will it matter if these urls are re-wrtiien by a .htaccess file?for example show.php?id=3 is re-written to be some-text-3.php where 3 is the id of the file[/quote]The problem could be very well due to the rewrite, I have no clue. Quote Link to comment Share on other sites More sharing options...
asgsoft Posted April 16, 2006 Author Share Posted April 16, 2006 because when I go to show.php?od=7&lang=en it echos en correctly.What do you recommend I do? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.