Re: Translation
| From: | olivier hericord | Date: | Fri, 22 Mar 2002 18:39:58 +0000 |
| Subject: | Re: Translation | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-3285@lists.php.net to get a copy of this message | ||
Here is the solution i choose to translate...
__________________file: langage.inc.php______________________________
<?
switch($lang)
{
case "french":
$traduction = array(
"medecin" => "MÈdecin",
"site" => "Sites",
"modifier" => "Modifier",
"effacer" => "Effacer",
);
break;
case "english":
$traduction = array(
"medecin" => "Doctor",
"site" => "Sites",
"modifier" => "Change",
"effacer" => "Delete",
);
break;
}
?>
_____________________________________________________________________
This file contains arrays that contains all the translations
__________________file: translate.class.php___________________________
<?
class translate
{
function traducteur($verbose)
{
global $lang;
include("code/langage.inc.php");
return ($traduction[$verbose]);
}
}
?>
______________________________________________________________________
This is the class that handle the translation
__________________file: function.traducteur.php___________________________
<?
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: traducteur
* Purpose: traducteur
* -------------------------------------------------------------
*/
function smarty_function_traducteur()
{
extract(func_get_arg(0));
$trad = new translate;
echo $trad->traducteur($VERBOSE);
}
/* vim: set expandtab: */
?>
______________________________________________________________________
This is the smarty plugin that handle the traduction (calling the translate
class)