Jump to content

Archived

This topic is now archived and is closed to further replies.

asgsoft

Language Packs

Recommended Posts

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?

Share this post


Link to post
Share on other sites
[!--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?

Share this post


Link to post
Share on other sites
in the english tpl files I have a variable called en_tnos and in french tpl file i have fr_tnos

Share this post


Link to post
Share on other sites
[!--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]
<?php
echo $_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]

Share this post


Link to post
Share on other sites
[!--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]
<?php
echo $_GET['lang'];
?>
[/code]
What is then the result shown in your browser?
[/quote]

It echos nothing
Will 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.

Share this post


Link to post
Share on other sites
[!--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.

Share this post


Link to post
Share on other sites
because when I go to show.php?od=7&lang=en it echos en correctly.

What do you recommend I do?

Share this post


Link to post
Share on other sites

×

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.