CREATE TABLE `traductions` (
`cle` VARCHAR( 30 ) NOT NULL ,
`texte_fr` TEXT NOT NULL ,
`texte_en` TEXT NOT NULL ,
`texte_es` TEXT NOT NULL ,
PRIMARY KEY ( `cle` )
);
INSERT INTO traductions (cle, texte_fr, texte_en, texte_es)
VALUES ('tr_HomePage', 'Page d''accueil',
'HomePage', 'Pagina Principal');
INSERT INTO traductions (cle, texte_fr, texte_en, texte_es)
VALUES ('tr_VotrePub', 'Votre publicité', 'Advertising',
'Su publicidad');
<?php
// --- Fonction pour extraire une traduction de la base de données
function traduction ($cle, $lang) {
$champ = 'texte_' . $lang;
$cde = "select $champ as texte from traductions
where cle like '$mot'";
$result = mysql_query($cde);
while($row = mysql_fetch_object($result)) {
return($row->texte);
}
return('');
}
echo '<a href="index.php?lang=en">'
. traduction ('tr_HomePage', $lang) . '</a><br>';
?>
|
|