Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multi language website

Status
Not open for further replies.

jogairan

IS-IT--Management
Aug 7, 2001
19
US
Hi,

We have a website that is soon to be translated into a bunch of different languages. The user will pick their language and enter the site on the first page.

We are looking to redesign the site so that a page does not have to be created manualy everytime there is a change or a new section added. We want to have to edit the english portion, for example, and the rest of the languages automaticaly get updated as the user picks their respective lingo.

I have been told that mysql/php is the way to go but i have no clue where to start and how to proceed. Anyhelp is truly appriciated.

Thank you much
 
Perhaps you should try a product that has been created already:
i.e. phpnuke as this has been tried and tested and has many languages installed already:

Reality is built on a foundation of dreams.
 
you basically need to abstract the textual content from the page design. you then store each language content either in text files or database fields etc and retrieve them based on the page that is called and the user lingo preference.

a *very* basic example follows (here the language content is stored in variables to save you having to create text files to run the code):

Code:
<?
session_start;
$en[0]= "Hello";
$en[1]="and";
$en[2]="Goodbye";
$es[0]="Hola!";
$es[1] = "y";
$es[2] = "Adios";
$fr[0] = "Bonjour";
$fr[1] = "et";
$fr[2] = "Au revoir";
$defaultlang = "en"; //change to change the default language

$page = $_SERVER['PHP_SELF']; //this just creates a dynamic reference to the page

$lang = isset($_GET['lang'])
			? $_GET['lang']
			: ((isset($_SESSION['lang'])
			?	$_SESSION['lang']
			:	$defaultlang) 
			);		// this construct tests to see whether the user has expressly requested a language.  if not it then tests to see whether he has previously requested a language.  If not it selects the default

$_SESSION['lang'] = $lang;  //remember the user's selection for next time

//the sections in <?=  ? > brackets causes php to place the $page variable.  this is one way to build a templating system (there are better ways)
?>

<div>
Talk to me in: <a href="<?=$page?>?lang=en">English</a> | <a href="<?=$page?>?lang=fr">Francais</a> | <a href="<?=$page?>?lang=es">Espanol</a>
<div>

<hr/>

<?
	echo ${$lang}[0] . " " . ${$lang}[1] . " " . ${$lang}[2];
?>

note that although there are multi-lingual templating systems out there (such as smarty) you really need to learn what you are doing in abstract before you attempt to use any of them.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top