Jump to content

How to create a script for switching two languages


janggu

Recommended Posts

Hi there,

 

I was wondering if anyone could help me with creating a script for switching two languages. I am thinking of using a folder structure or an extension of file names in URL. For example, this script will look for the different extension or the folder structure as follow.

 

about-e.php | about-f.php or

en/about.php | fr/about.php

 

I am open for any other suggestions and thank you!

have a look into php templating.

that way you will only have 1page but the option of 2values eng of fr

 

heres an example:

 

index.php

<?php
$lang = "";

include("variables.php");

if $lang = "EN"; {
include("templateEN.html");
} else
include("templateFR.html");
}
?>

 

variables.php

<?php
$TPLEN["title"] = "This is Magic!";
$TPLFR["title"] = "This is Magic!";
$TPLEN["HEADLINE"] = "Hello"; // This is ENGLISH
$TPLFR["HEADLINE"] = "Bonjour"; // This is FRENCH
?>

 

templateEN.html

<html>
<head><title><?=$TPLEN["title"]?></title></head>
<body>
<H1><?=$TPLEN["HEADLINE"]?></H1>
</body>
</html>

 

templateFR.html

<html>
<head><title><?=$TPLFR["title"]?></title></head>
<body>
<H1><?=$TPLFR["HEADLINE"]?></H1>
</body>
</html>

 

You can then goto - http://www.yourdomain.com/index.php?lang=EN

Archived

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

×
×
  • 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.