Jump to content

Language Packs


asgsoft

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?
Link to comment
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?
Link to comment
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]
Link to comment
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.
Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.