X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7D?a=blobdiff_plain;f=www%2Fecrire%2Finc%2Ftraduire.php;h=989e763bfe64ce12c7bebee8744167e280995785;hb=d18fcb8f27a4016e3fa7b50a9b2255d529dca543;hp=9544272b6ba25d747ad2de5655584496cc578894;hpb=52cf8ed924d5dcd0c28dde4b6c3196be6ec2d4f7;p=ptitvelo%2Fweb%2Fwww.git diff --git a/www/ecrire/inc/traduire.php b/www/ecrire/inc/traduire.php index 9544272..989e763 100644 --- a/www/ecrire/inc/traduire.php +++ b/www/ecrire/inc/traduire.php @@ -3,7 +3,7 @@ /***************************************************************************\ * SPIP, Systeme de publication pour l'internet * * * - * Copyright (c) 2001-2012 * + * Copyright (c) 2001-2014 * * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James * * * * Ce programme est un logiciel libre distribue sous licence GNU/GPL. * @@ -118,28 +118,35 @@ function inc_traduire_dist($ori, $lang) { static $deja_vu = array(); static $local = array(); - if (isset($deja_vu[$lang][$ori])) + if (isset($deja_vu[$lang][$ori]) AND (_request('var_mode') != 'traduction')) return $deja_vu[$lang][$ori]; // modules demandes explicitement cf MODULES_IDIOMES if (strpos($ori,':')) { list($modules,$code) = explode(':',$ori,2); $modules = explode('|', $modules); + $ori_complet = $ori; } else { $modules = array('spip', 'ecrire'); $code = $ori; + $ori_complet = implode('|', $modules) . ':' . $ori; } $text = ''; // parcourir tous les modules jusqu'a ce qu'on trouve foreach ($modules as $module) { $var = "i18n_".$module."_".$lang; + if (empty($GLOBALS[$var])) { charger_langue($lang, $module); - // surcharge perso -- on cherche (lang/)local_xx.php ... - if (!isset($local['local_'.$lang])) + // surcharge perso + // -- on cherche (lang/)local_xx.php ... + if (!isset($local['local_'.$lang])) { + // redéfinir la langue en cours pour les surcharges (chercher_langue a pu le changer) + $GLOBALS['idx_lang']= $var; $local['local_'.$lang] = chercher_module_lang('local', $lang); + } if ($local['local_'.$lang]) surcharger_langue($local['local_'.$lang]); // ... puis (lang/)local.php @@ -148,7 +155,9 @@ function inc_traduire_dist($ori, $lang) { if ($local['local']) surcharger_langue($local['local']); } + if (isset($GLOBALS[$var][$code])) { + $module_retenu = $module; $text = $GLOBALS[$var][$code]; break; } @@ -156,12 +165,17 @@ function inc_traduire_dist($ori, $lang) { // Retour aux sources si la chaine est absente dans la langue cible ; // on essaie d'abord la langue du site, puis a defaut la langue fr + $langue_retenue = $lang; if (!strlen($text) AND $lang !== 'fr') { - if ($lang !== $GLOBALS['meta']['langue_site']) + if ($lang !== $GLOBALS['meta']['langue_site']) { $text = inc_traduire_dist($ori, $GLOBALS['meta']['langue_site']); - else + $langue_retenue = (!strlen($text) ? $GLOBALS['meta']['langue_site'] : ''); + } + else { $text = inc_traduire_dist($ori, 'fr'); + $langue_retenue = (!strlen($text) ? 'fr' : ''); + } } // Supprimer la mention ou @@ -176,8 +190,20 @@ function inc_traduire_dist($ori, $lang) { $text = charset2unicode($text,'utf-8'); } - $deja_vu[$lang][$ori] = $text; + if (_request('var_mode') == 'traduction') { + if ($text) { + $classe = 'debug-traduction' . ($module_retenu == 'ecrire' ? '-prive' : ''); + $text = '' . $text . ''; + $text = str_replace( + array("$module_retenu:", "$module_retenu|"), + array("*$module_retenu*:", "*$module_retenu*|"), + $text); + } + } + else { + $deja_vu[$lang][$ori] = $text; + } return $text; } -?> +?> \ No newline at end of file