Jump to content


Photo

Language Packs


  • Please log in to reply
6 replies to this topic

#1 asgsoft

asgsoft
  • Members
  • PipPipPip
  • Advanced Member
  • 56 posts

Posted 16 April 2006 - 10:26 AM

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:

<?php
$lang = $_GET['lang'];
if($lang == "fr" || $lang == "FR"){
include "fr.tpl";
$lang = "fr";
}else{
include "en.tpl";
$lang = "en";
}
?>


Another thing.

If I want to get a variable from the tpl file how will i do that?

At the moment I have :

echo "".$lang."_".tnos." $num_rows";

to say the number of rows in the chosen language but it doesn't say anything.

Where have I gone wrong?

Free SEO and Domain tools |HTML ENT| Your Source to expired domains with PageRank & tips


#2 Honoré

Honoré
  • Members
  • PipPipPip
  • Advanced Member
  • 66 posts
  • LocationAntwerp - Belgium

Posted 16 April 2006 - 10:38 AM

[!--quoteo(post=365266:date=Apr 16 2006, 12:26 PM:name=asgsoft)--][div class=\'quotetop\']QUOTE(asgsoft @ Apr 16 2006, 12:26 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
At the moment I have :
echo "".$lang."_".tnos." $num_rows";
[/quote]
What is tnos? Is it a variable? Should it be $tnos?

#3 asgsoft

asgsoft
  • Members
  • PipPipPip
  • Advanced Member
  • 56 posts

Posted 16 April 2006 - 10:43 AM

in the english tpl files I have a variable called en_tnos and in french tpl file i have fr_tnos

Free SEO and Domain tools |HTML ENT| Your Source to expired domains with PageRank & tips


#4 Honoré

Honoré
  • Members
  • PipPipPip
  • Advanced Member
  • 66 posts
  • LocationAntwerp - Belgium

Posted 16 April 2006 - 10:49 AM

[!--quoteo(post=365266:date=Apr 16 2006, 12:26 PM:name=asgsoft)--][div class=\'quotetop\']QUOTE(asgsoft @ Apr 16 2006, 12:26 PM) View Post[/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:
<?php
echo $_GET['lang'];
?>
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) View Post[/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
echo $lang."_"."$tnos $numrows";


#5 asgsoft

asgsoft
  • Members
  • PipPipPip
  • Advanced Member
  • 56 posts

Posted 16 April 2006 - 11:01 AM

[!--quoteo(post=365269:date=Apr 16 2006, 05:49 AM:name=Honoré)--][div class=\'quotetop\']QUOTE(Honoré @ Apr 16 2006, 05:49 AM) View Post[/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:
<?php
echo $_GET['lang'];
?>
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) View Post[/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
echo $lang."_"."$tnos $numrows";
[/quote]
Good idea I will use it and try it as soon as the above works.

Free SEO and Domain tools |HTML ENT| Your Source to expired domains with PageRank & tips


#6 Honoré

Honoré
  • Members
  • PipPipPip
  • Advanced Member
  • 66 posts
  • LocationAntwerp - Belgium

Posted 16 April 2006 - 11:05 AM

[!--quoteo(post=365270:date=Apr 16 2006, 01:01 PM:name=asgsoft)--][div class=\'quotetop\']QUOTE(asgsoft @ Apr 16 2006, 01:01 PM) View Post[/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.

#7 asgsoft

asgsoft
  • Members
  • PipPipPip
  • Advanced Member
  • 56 posts

Posted 16 April 2006 - 11:19 AM

because when I go to show.php?od=7&lang=en it echos en correctly.

What do you recommend I do?

Free SEO and Domain tools |HTML ENT| Your Source to expired domains with PageRank & tips





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users