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!

Link to comment
Share on other sites

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

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.