@@ -17,7 +17,7 @@ discard block  | 
                                                    ||
| 17 | 17 | **/  | 
                                                        
| 18 | 18 | |
| 19 | 19 |  if (!defined('_ECRIRE_INC_VERSION')) { | 
                                                        
| 20 | - return;  | 
                                                        |
| 20 | + return;  | 
                                                        |
| 21 | 21 | }  | 
                                                        
| 22 | 22 | |
| 23 | 23 | /**  | 
                                                        
@@ -38,20 +38,20 @@ discard block  | 
                                                    ||
| 38 | 38 | * Liste des fichiers de langue trouvés, dans l'ordre des chemins  | 
                                                        
| 39 | 39 | */  | 
                                                        
| 40 | 40 |  function find_langs_in_path($file, $dirname = 'lang') { | 
                                                        
| 41 | - static $dirs = array();  | 
                                                        |
| 42 | - $liste = array();  | 
                                                        |
| 43 | -	foreach (creer_chemin() as $dir) { | 
                                                        |
| 44 | -		if (!isset($dirs[$a = $dir . $dirname])) { | 
                                                        |
| 45 | - $dirs[$a] = (is_dir($a) || !$a);  | 
                                                        |
| 46 | - }  | 
                                                        |
| 47 | -		if ($dirs[$a]) { | 
                                                        |
| 48 | -			if (is_readable($a .= $file)) { | 
                                                        |
| 49 | - $liste[] = $a;  | 
                                                        |
| 50 | - }  | 
                                                        |
| 51 | - }  | 
                                                        |
| 52 | - }  | 
                                                        |
| 41 | + static $dirs = array();  | 
                                                        |
| 42 | + $liste = array();  | 
                                                        |
| 43 | +    foreach (creer_chemin() as $dir) { | 
                                                        |
| 44 | +        if (!isset($dirs[$a = $dir . $dirname])) { | 
                                                        |
| 45 | + $dirs[$a] = (is_dir($a) || !$a);  | 
                                                        |
| 46 | + }  | 
                                                        |
| 47 | +        if ($dirs[$a]) { | 
                                                        |
| 48 | +            if (is_readable($a .= $file)) { | 
                                                        |
| 49 | + $liste[] = $a;  | 
                                                        |
| 50 | + }  | 
                                                        |
| 51 | + }  | 
                                                        |
| 52 | + }  | 
                                                        |
| 53 | 53 | |
| 54 | - return array_reverse($liste);  | 
                                                        |
| 54 | + return array_reverse($liste);  | 
                                                        |
| 55 | 55 | }  | 
                                                        
| 56 | 56 | |
| 57 | 57 | /**  | 
                                                        
@@ -66,22 +66,22 @@ discard block  | 
                                                    ||
| 66 | 66 | * Liste des fichiers touvés pour ce module et cette langue.  | 
                                                        
| 67 | 67 | **/  | 
                                                        
| 68 | 68 |  function chercher_module_lang($module, $lang = '') { | 
                                                        
| 69 | -	if ($lang) { | 
                                                        |
| 70 | - $lang = '_' . $lang;  | 
                                                        |
| 71 | - }  | 
                                                        |
| 69 | +    if ($lang) { | 
                                                        |
| 70 | + $lang = '_' . $lang;  | 
                                                        |
| 71 | + }  | 
                                                        |
| 72 | 72 | |
| 73 | - // 1) dans un repertoire nomme lang/ se trouvant sur le chemin  | 
                                                        |
| 74 | - if ($f = ($module == 'local'  | 
                                                        |
| 75 | - ? find_in_path($module . $lang . '.php', 'lang/')  | 
                                                        |
| 76 | - : find_langs_in_path($module . $lang . '.php', 'lang/'))  | 
                                                        |
| 77 | -	) { | 
                                                        |
| 78 | - return is_array($f) ? $f : array($f);  | 
                                                        |
| 79 | - }  | 
                                                        |
| 73 | + // 1) dans un repertoire nomme lang/ se trouvant sur le chemin  | 
                                                        |
| 74 | + if ($f = ($module == 'local'  | 
                                                        |
| 75 | + ? find_in_path($module . $lang . '.php', 'lang/')  | 
                                                        |
| 76 | + : find_langs_in_path($module . $lang . '.php', 'lang/'))  | 
                                                        |
| 77 | +    ) { | 
                                                        |
| 78 | + return is_array($f) ? $f : array($f);  | 
                                                        |
| 79 | + }  | 
                                                        |
| 80 | 80 | |
| 81 | - // 2) directement dans le chemin (old style, uniquement pour local)  | 
                                                        |
| 82 | - return (($module == 'local') or strpos($module, '/'))  | 
                                                        |
| 83 | - ? (($f = find_in_path($module . $lang . '.php')) ? array($f) : false)  | 
                                                        |
| 84 | - : false;  | 
                                                        |
| 81 | + // 2) directement dans le chemin (old style, uniquement pour local)  | 
                                                        |
| 82 | + return (($module == 'local') or strpos($module, '/'))  | 
                                                        |
| 83 | + ? (($f = find_in_path($module . $lang . '.php')) ? array($f) : false)  | 
                                                        |
| 84 | + : false;  | 
                                                        |
| 85 | 85 | }  | 
                                                        
| 86 | 86 | |
| 87 | 87 | /**  | 
                                                        
@@ -103,33 +103,33 @@ discard block  | 
                                                    ||
| 103 | 103 | * @return string Langue du module chargé, sinon chaîne vide.  | 
                                                        
| 104 | 104 | **/  | 
                                                        
| 105 | 105 |  function charger_langue($lang, $module = 'spip') { | 
                                                        
| 106 | - static $langs = array();  | 
                                                        |
| 107 | - $var = 'i18n_' . $module . '_' . $lang;  | 
                                                        |
| 108 | -	if (!isset($langs[$lang])) { | 
                                                        |
| 109 | - $langs[$lang] = array();  | 
                                                        |
| 110 | -		if ($lang) { | 
                                                        |
| 111 | - $langs[$lang][] = $lang;  | 
                                                        |
| 112 | -			if (strpos($lang, '_') !== false) { | 
                                                        |
| 113 | -				$l = explode('_', $lang); | 
                                                        |
| 114 | - $langs[$lang][] = reset($l);  | 
                                                        |
| 115 | - }  | 
                                                        |
| 116 | - }  | 
                                                        |
| 117 | - $langs[$lang][] = $GLOBALS['meta']['langue_site'];  | 
                                                        |
| 118 | - $langs[$lang][] = _LANGUE_PAR_DEFAUT;  | 
                                                        |
| 119 | - }  | 
                                                        |
| 120 | -	foreach ($langs[$lang] as $l) { | 
                                                        |
| 121 | -		if ($fichiers_lang = chercher_module_lang($module, $l)) { | 
                                                        |
| 122 | - $GLOBALS['idx_lang'] = 'i18n_' . $module . '_' . $l;  | 
                                                        |
| 123 | - include(array_shift($fichiers_lang));  | 
                                                        |
| 124 | - surcharger_langue($fichiers_lang);  | 
                                                        |
| 125 | -			if ($l !== $lang) { | 
                                                        |
| 126 | - $GLOBALS[$var] = &$GLOBALS['i18n_' . $module . '_' . $l];  | 
                                                        |
| 127 | - }  | 
                                                        |
| 128 | - $GLOBALS['lang_' . $var] = $l;  | 
                                                        |
| 129 | -			#spip_log("module de langue : ${module}_$l.php", 'traduire'); | 
                                                        |
| 130 | - break;  | 
                                                        |
| 131 | - }  | 
                                                        |
| 132 | - }  | 
                                                        |
| 106 | + static $langs = array();  | 
                                                        |
| 107 | + $var = 'i18n_' . $module . '_' . $lang;  | 
                                                        |
| 108 | +    if (!isset($langs[$lang])) { | 
                                                        |
| 109 | + $langs[$lang] = array();  | 
                                                        |
| 110 | +        if ($lang) { | 
                                                        |
| 111 | + $langs[$lang][] = $lang;  | 
                                                        |
| 112 | +            if (strpos($lang, '_') !== false) { | 
                                                        |
| 113 | +                $l = explode('_', $lang); | 
                                                        |
| 114 | + $langs[$lang][] = reset($l);  | 
                                                        |
| 115 | + }  | 
                                                        |
| 116 | + }  | 
                                                        |
| 117 | + $langs[$lang][] = $GLOBALS['meta']['langue_site'];  | 
                                                        |
| 118 | + $langs[$lang][] = _LANGUE_PAR_DEFAUT;  | 
                                                        |
| 119 | + }  | 
                                                        |
| 120 | +    foreach ($langs[$lang] as $l) { | 
                                                        |
| 121 | +        if ($fichiers_lang = chercher_module_lang($module, $l)) { | 
                                                        |
| 122 | + $GLOBALS['idx_lang'] = 'i18n_' . $module . '_' . $l;  | 
                                                        |
| 123 | + include(array_shift($fichiers_lang));  | 
                                                        |
| 124 | + surcharger_langue($fichiers_lang);  | 
                                                        |
| 125 | +            if ($l !== $lang) { | 
                                                        |
| 126 | + $GLOBALS[$var] = &$GLOBALS['i18n_' . $module . '_' . $l];  | 
                                                        |
| 127 | + }  | 
                                                        |
| 128 | + $GLOBALS['lang_' . $var] = $l;  | 
                                                        |
| 129 | +            #spip_log("module de langue : ${module}_$l.php", 'traduire'); | 
                                                        |
| 130 | + break;  | 
                                                        |
| 131 | + }  | 
                                                        |
| 132 | + }  | 
                                                        |
| 133 | 133 | }  | 
                                                        
| 134 | 134 | |
| 135 | 135 | /**  | 
                                                        
@@ -149,50 +149,50 @@ discard block  | 
                                                    ||
| 149 | 149 | * Liste des chemins de fichiers de langue à surcharger.  | 
                                                        
| 150 | 150 | **/  | 
                                                        
| 151 | 151 |  function surcharger_langue($fichiers) { | 
                                                        
| 152 | - static $surcharges = array();  | 
                                                        |
| 153 | -	if (!isset($GLOBALS['idx_lang'])) { | 
                                                        |
| 154 | - return;  | 
                                                        |
| 155 | - }  | 
                                                        |
| 152 | + static $surcharges = array();  | 
                                                        |
| 153 | +    if (!isset($GLOBALS['idx_lang'])) { | 
                                                        |
| 154 | + return;  | 
                                                        |
| 155 | + }  | 
                                                        |
| 156 | 156 | |
| 157 | -	if (!is_array($fichiers)) { | 
                                                        |
| 158 | - $fichiers = array($fichiers);  | 
                                                        |
| 159 | - }  | 
                                                        |
| 160 | -	if (!count($fichiers)) { | 
                                                        |
| 161 | - return;  | 
                                                        |
| 162 | - }  | 
                                                        |
| 163 | -	foreach ($fichiers as $fichier) { | 
                                                        |
| 164 | -		if (!isset($surcharges[$fichier])) { | 
                                                        |
| 165 | - $idx_lang_normal = $GLOBALS['idx_lang'];  | 
                                                        |
| 166 | - $GLOBALS['idx_lang'] = $GLOBALS['idx_lang'] . '@temporaire';  | 
                                                        |
| 167 | - include($fichier);  | 
                                                        |
| 168 | - $surcharges[$fichier] = $GLOBALS[$GLOBALS['idx_lang']];  | 
                                                        |
| 169 | - unset($GLOBALS[$GLOBALS['idx_lang']]);  | 
                                                        |
| 170 | - $GLOBALS['idx_lang'] = $idx_lang_normal;  | 
                                                        |
| 171 | - }  | 
                                                        |
| 172 | -		if (is_array($surcharges[$fichier])) { | 
                                                        |
| 173 | - $GLOBALS[$GLOBALS['idx_lang']] = array_merge(  | 
                                                        |
| 174 | - (isset($GLOBALS[$GLOBALS['idx_lang']]) ? (array)$GLOBALS[$GLOBALS['idx_lang']] : array()),  | 
                                                        |
| 175 | - $surcharges[$fichier]  | 
                                                        |
| 176 | - );  | 
                                                        |
| 177 | - }  | 
                                                        |
| 178 | - }  | 
                                                        |
| 157 | +    if (!is_array($fichiers)) { | 
                                                        |
| 158 | + $fichiers = array($fichiers);  | 
                                                        |
| 159 | + }  | 
                                                        |
| 160 | +    if (!count($fichiers)) { | 
                                                        |
| 161 | + return;  | 
                                                        |
| 162 | + }  | 
                                                        |
| 163 | +    foreach ($fichiers as $fichier) { | 
                                                        |
| 164 | +        if (!isset($surcharges[$fichier])) { | 
                                                        |
| 165 | + $idx_lang_normal = $GLOBALS['idx_lang'];  | 
                                                        |
| 166 | + $GLOBALS['idx_lang'] = $GLOBALS['idx_lang'] . '@temporaire';  | 
                                                        |
| 167 | + include($fichier);  | 
                                                        |
| 168 | + $surcharges[$fichier] = $GLOBALS[$GLOBALS['idx_lang']];  | 
                                                        |
| 169 | + unset($GLOBALS[$GLOBALS['idx_lang']]);  | 
                                                        |
| 170 | + $GLOBALS['idx_lang'] = $idx_lang_normal;  | 
                                                        |
| 171 | + }  | 
                                                        |
| 172 | +        if (is_array($surcharges[$fichier])) { | 
                                                        |
| 173 | + $GLOBALS[$GLOBALS['idx_lang']] = array_merge(  | 
                                                        |
| 174 | + (isset($GLOBALS[$GLOBALS['idx_lang']]) ? (array)$GLOBALS[$GLOBALS['idx_lang']] : array()),  | 
                                                        |
| 175 | + $surcharges[$fichier]  | 
                                                        |
| 176 | + );  | 
                                                        |
| 177 | + }  | 
                                                        |
| 178 | + }  | 
                                                        |
| 179 | 179 | }  | 
                                                        
| 180 | 180 | |
| 181 | 181 | |
| 182 | 182 | |
| 183 | 183 |  class SPIP_Traductions_Description { | 
                                                        
| 184 | - /** @var string code de langue (hors module) */  | 
                                                        |
| 185 | - public $code;  | 
                                                        |
| 186 | - /** @var string nom du module de langue */  | 
                                                        |
| 187 | - public $module;  | 
                                                        |
| 188 | - /** @var string langue de la traduction */  | 
                                                        |
| 189 | - public $langue;  | 
                                                        |
| 190 | - /** @var string traduction */  | 
                                                        |
| 191 | - public $texte;  | 
                                                        |
| 192 | - /** @var string var mode particulier appliqué ? */  | 
                                                        |
| 193 | - public $mode;  | 
                                                        |
| 194 | - /** @var bool Corrections des textes appliqué ? */  | 
                                                        |
| 195 | - public $corrections = false;  | 
                                                        |
| 184 | + /** @var string code de langue (hors module) */  | 
                                                        |
| 185 | + public $code;  | 
                                                        |
| 186 | + /** @var string nom du module de langue */  | 
                                                        |
| 187 | + public $module;  | 
                                                        |
| 188 | + /** @var string langue de la traduction */  | 
                                                        |
| 189 | + public $langue;  | 
                                                        |
| 190 | + /** @var string traduction */  | 
                                                        |
| 191 | + public $texte;  | 
                                                        |
| 192 | + /** @var string var mode particulier appliqué ? */  | 
                                                        |
| 193 | + public $mode;  | 
                                                        |
| 194 | + /** @var bool Corrections des textes appliqué ? */  | 
                                                        |
| 195 | + public $corrections = false;  | 
                                                        |
| 196 | 196 | }  | 
                                                        
| 197 | 197 | |
| 198 | 198 | |
@@ -234,96 +234,96 @@ discard block  | 
                                                    ||
| 234 | 234 | * - SPIP_Traductions_Description : traduction et description (texte, module, langue)  | 
                                                        
| 235 | 235 | **/  | 
                                                        
| 236 | 236 |  function inc_traduire_dist($ori, $lang, $raw = false) { | 
                                                        
| 237 | - static $deja_vu = array();  | 
                                                        |
| 238 | - static $local = array();  | 
                                                        |
| 237 | + static $deja_vu = array();  | 
                                                        |
| 238 | + static $local = array();  | 
                                                        |
| 239 | 239 | |
| 240 | -	if (isset($deja_vu[$lang][$ori]) and (_request('var_mode') != 'traduction')) { | 
                                                        |
| 241 | - return $raw ? $deja_vu[$lang][$ori] : $deja_vu[$lang][$ori]->texte;  | 
                                                        |
| 242 | - }  | 
                                                        |
| 240 | +    if (isset($deja_vu[$lang][$ori]) and (_request('var_mode') != 'traduction')) { | 
                                                        |
| 241 | + return $raw ? $deja_vu[$lang][$ori] : $deja_vu[$lang][$ori]->texte;  | 
                                                        |
| 242 | + }  | 
                                                        |
| 243 | 243 | |
| 244 | - // modules demandes explicitement <xxx|yyy|zzz:code> cf MODULES_IDIOMES  | 
                                                        |
| 245 | -	if (strpos($ori, ':')) { | 
                                                        |
| 246 | -		list($modules, $code) = explode(':', $ori, 2); | 
                                                        |
| 247 | -		$modules = explode('|', $modules); | 
                                                        |
| 248 | - $ori_complet = $ori;  | 
                                                        |
| 249 | -	} else { | 
                                                        |
| 250 | -		$modules = array('spip', 'ecrire'); | 
                                                        |
| 251 | - $code = $ori;  | 
                                                        |
| 252 | -		$ori_complet = implode('|', $modules) . ':' . $ori; | 
                                                        |
| 253 | - }  | 
                                                        |
| 244 | + // modules demandes explicitement <xxx|yyy|zzz:code> cf MODULES_IDIOMES  | 
                                                        |
| 245 | +    if (strpos($ori, ':')) { | 
                                                        |
| 246 | +        list($modules, $code) = explode(':', $ori, 2); | 
                                                        |
| 247 | +        $modules = explode('|', $modules); | 
                                                        |
| 248 | + $ori_complet = $ori;  | 
                                                        |
| 249 | +    } else { | 
                                                        |
| 250 | +        $modules = array('spip', 'ecrire'); | 
                                                        |
| 251 | + $code = $ori;  | 
                                                        |
| 252 | +        $ori_complet = implode('|', $modules) . ':' . $ori; | 
                                                        |
| 253 | + }  | 
                                                        |
| 254 | 254 | |
| 255 | - $desc = new SPIP_Traductions_Description();  | 
                                                        |
| 255 | + $desc = new SPIP_Traductions_Description();  | 
                                                        |
| 256 | 256 | |
| 257 | - // parcourir tous les modules jusqu'a ce qu'on trouve  | 
                                                        |
| 258 | -	foreach ($modules as $module) { | 
                                                        |
| 259 | - $var = "i18n_" . $module . "_" . $lang;  | 
                                                        |
| 257 | + // parcourir tous les modules jusqu'a ce qu'on trouve  | 
                                                        |
| 258 | +    foreach ($modules as $module) { | 
                                                        |
| 259 | + $var = "i18n_" . $module . "_" . $lang;  | 
                                                        |
| 260 | 260 | |
| 261 | -		if (empty($GLOBALS[$var])) { | 
                                                        |
| 262 | - charger_langue($lang, $module);  | 
                                                        |
| 263 | - // surcharges persos -- on cherche  | 
                                                        |
| 264 | - // (lang/)local_xx.php et/ou (lang/)local.php ...  | 
                                                        |
| 265 | -			if (!isset($local['local_' . $lang])) { | 
                                                        |
| 266 | - // redéfinir la langue en cours pour les surcharges (chercher_langue a pu le changer)  | 
                                                        |
| 267 | - $GLOBALS['idx_lang'] = $var;  | 
                                                        |
| 268 | - // ... (lang/)local_xx.php  | 
                                                        |
| 269 | -				$local['local_' . $lang] = chercher_module_lang('local', $lang); | 
                                                        |
| 270 | - }  | 
                                                        |
| 271 | -			if ($local['local_' . $lang]) { | 
                                                        |
| 272 | - surcharger_langue($local['local_' . $lang]);  | 
                                                        |
| 273 | - }  | 
                                                        |
| 274 | - // ... puis (lang/)local.php  | 
                                                        |
| 275 | -			if (!isset($local['local'])) { | 
                                                        |
| 276 | -				$local['local'] = chercher_module_lang('local'); | 
                                                        |
| 277 | - }  | 
                                                        |
| 278 | -			if ($local['local']) { | 
                                                        |
| 279 | - surcharger_langue($local['local']);  | 
                                                        |
| 280 | - }  | 
                                                        |
| 281 | - }  | 
                                                        |
| 261 | +        if (empty($GLOBALS[$var])) { | 
                                                        |
| 262 | + charger_langue($lang, $module);  | 
                                                        |
| 263 | + // surcharges persos -- on cherche  | 
                                                        |
| 264 | + // (lang/)local_xx.php et/ou (lang/)local.php ...  | 
                                                        |
| 265 | +            if (!isset($local['local_' . $lang])) { | 
                                                        |
| 266 | + // redéfinir la langue en cours pour les surcharges (chercher_langue a pu le changer)  | 
                                                        |
| 267 | + $GLOBALS['idx_lang'] = $var;  | 
                                                        |
| 268 | + // ... (lang/)local_xx.php  | 
                                                        |
| 269 | +                $local['local_' . $lang] = chercher_module_lang('local', $lang); | 
                                                        |
| 270 | + }  | 
                                                        |
| 271 | +            if ($local['local_' . $lang]) { | 
                                                        |
| 272 | + surcharger_langue($local['local_' . $lang]);  | 
                                                        |
| 273 | + }  | 
                                                        |
| 274 | + // ... puis (lang/)local.php  | 
                                                        |
| 275 | +            if (!isset($local['local'])) { | 
                                                        |
| 276 | +                $local['local'] = chercher_module_lang('local'); | 
                                                        |
| 277 | + }  | 
                                                        |
| 278 | +            if ($local['local']) { | 
                                                        |
| 279 | + surcharger_langue($local['local']);  | 
                                                        |
| 280 | + }  | 
                                                        |
| 281 | + }  | 
                                                        |
| 282 | 282 | |
| 283 | -		if (isset($GLOBALS[$var][$code])) { | 
                                                        |
| 284 | - $desc->code = $code;  | 
                                                        |
| 285 | - $desc->module = $module;  | 
                                                        |
| 286 | - if (isset($GLOBALS['lang_' . $var]))  | 
                                                        |
| 287 | - $desc->langue = $GLOBALS['lang_' . $var];  | 
                                                        |
| 288 | - $desc->texte = $GLOBALS[$var][$code];  | 
                                                        |
| 289 | - break;  | 
                                                        |
| 290 | - }  | 
                                                        |
| 291 | - }  | 
                                                        |
| 283 | +        if (isset($GLOBALS[$var][$code])) { | 
                                                        |
| 284 | + $desc->code = $code;  | 
                                                        |
| 285 | + $desc->module = $module;  | 
                                                        |
| 286 | + if (isset($GLOBALS['lang_' . $var]))  | 
                                                        |
| 287 | + $desc->langue = $GLOBALS['lang_' . $var];  | 
                                                        |
| 288 | + $desc->texte = $GLOBALS[$var][$code];  | 
                                                        |
| 289 | + break;  | 
                                                        |
| 290 | + }  | 
                                                        |
| 291 | + }  | 
                                                        |
| 292 | 292 | |
| 293 | -	if (!$desc->corrections) { | 
                                                        |
| 294 | - $desc->corrections = true;  | 
                                                        |
| 295 | - // Retour aux sources si la chaine est absente dans la langue cible ;  | 
                                                        |
| 296 | - // on essaie d'abord la langue du site, puis a defaut la langue fr  | 
                                                        |
| 297 | -		if (!strlen($desc->texte) and $lang !== _LANGUE_PAR_DEFAUT) { | 
                                                        |
| 298 | -			if ($lang !== $GLOBALS['meta']['langue_site']) { | 
                                                        |
| 299 | - $desc = inc_traduire_dist($ori, $GLOBALS['meta']['langue_site'], true);  | 
                                                        |
| 300 | -			} else { | 
                                                        |
| 301 | - $desc = inc_traduire_dist($ori, _LANGUE_PAR_DEFAUT, true);  | 
                                                        |
| 302 | - }  | 
                                                        |
| 303 | - }  | 
                                                        |
| 293 | +    if (!$desc->corrections) { | 
                                                        |
| 294 | + $desc->corrections = true;  | 
                                                        |
| 295 | + // Retour aux sources si la chaine est absente dans la langue cible ;  | 
                                                        |
| 296 | + // on essaie d'abord la langue du site, puis a defaut la langue fr  | 
                                                        |
| 297 | +        if (!strlen($desc->texte) and $lang !== _LANGUE_PAR_DEFAUT) { | 
                                                        |
| 298 | +            if ($lang !== $GLOBALS['meta']['langue_site']) { | 
                                                        |
| 299 | + $desc = inc_traduire_dist($ori, $GLOBALS['meta']['langue_site'], true);  | 
                                                        |
| 300 | +            } else { | 
                                                        |
| 301 | + $desc = inc_traduire_dist($ori, _LANGUE_PAR_DEFAUT, true);  | 
                                                        |
| 302 | + }  | 
                                                        |
| 303 | + }  | 
                                                        |
| 304 | 304 | |
| 305 | - // Supprimer la mention <NEW> ou <MODIF>  | 
                                                        |
| 306 | -		if (substr($desc->texte, 0, 1) === '<') { | 
                                                        |
| 307 | -			$desc->texte = str_replace(array('<NEW>', '<MODIF>'), array(), $desc->texte); | 
                                                        |
| 308 | - }  | 
                                                        |
| 305 | + // Supprimer la mention <NEW> ou <MODIF>  | 
                                                        |
| 306 | +        if (substr($desc->texte, 0, 1) === '<') { | 
                                                        |
| 307 | +            $desc->texte = str_replace(array('<NEW>', '<MODIF>'), array(), $desc->texte); | 
                                                        |
| 308 | + }  | 
                                                        |
| 309 | 309 | |
| 310 | - // Si on n'est pas en utf-8, la chaine peut l'etre...  | 
                                                        |
| 311 | - // le cas echeant on la convertit en entites html &#xxx;  | 
                                                        |
| 312 | - if ((!isset($GLOBALS['meta']['charset']) or $GLOBALS['meta']['charset'] !== 'utf-8')  | 
                                                        |
| 313 | -			and preg_match(',[\x7f-\xff],S', $desc->texte) | 
                                                        |
| 314 | -		) { | 
                                                        |
| 315 | -			include_spip('inc/charsets'); | 
                                                        |
| 316 | - $desc->texte = charset2unicode($desc->texte, 'utf-8');  | 
                                                        |
| 317 | - }  | 
                                                        |
| 318 | - }  | 
                                                        |
| 310 | + // Si on n'est pas en utf-8, la chaine peut l'etre...  | 
                                                        |
| 311 | + // le cas echeant on la convertit en entites html &#xxx;  | 
                                                        |
| 312 | + if ((!isset($GLOBALS['meta']['charset']) or $GLOBALS['meta']['charset'] !== 'utf-8')  | 
                                                        |
| 313 | +            and preg_match(',[\x7f-\xff],S', $desc->texte) | 
                                                        |
| 314 | +        ) { | 
                                                        |
| 315 | +            include_spip('inc/charsets'); | 
                                                        |
| 316 | + $desc->texte = charset2unicode($desc->texte, 'utf-8');  | 
                                                        |
| 317 | + }  | 
                                                        |
| 318 | + }  | 
                                                        |
| 319 | 319 | |
| 320 | -	if (_request('var_mode') == 'traduction') { | 
                                                        |
| 321 | - $desc = definir_details_traduction($desc, $ori_complet);  | 
                                                        |
| 322 | -	} else { | 
                                                        |
| 323 | - $deja_vu[$lang][$ori] = $desc;  | 
                                                        |
| 324 | - }  | 
                                                        |
| 320 | +    if (_request('var_mode') == 'traduction') { | 
                                                        |
| 321 | + $desc = definir_details_traduction($desc, $ori_complet);  | 
                                                        |
| 322 | +    } else { | 
                                                        |
| 323 | + $deja_vu[$lang][$ori] = $desc;  | 
                                                        |
| 324 | + }  | 
                                                        |
| 325 | 325 | |
| 326 | - return $raw ? $desc : $desc->texte;  | 
                                                        |
| 326 | + return $raw ? $desc : $desc->texte;  | 
                                                        |
| 327 | 327 | }  | 
                                                        
| 328 | 328 | |
| 329 | 329 | /**  | 
                                                        
@@ -335,21 +335,21 @@ discard block  | 
                                                    ||
| 335 | 335 | * @return SPIP_Traductions_Description  | 
                                                        
| 336 | 336 | */  | 
                                                        
| 337 | 337 |  function definir_details_traduction($desc, $modules) { | 
                                                        
| 338 | -	if (!$desc->mode and $desc->texte) { | 
                                                        |
| 339 | - // ne pas modifier 2 fois l'affichage  | 
                                                        |
| 340 | - $desc->mode = 'traduction';  | 
                                                        |
| 341 | - $classe = 'debug-traduction' . ($desc->module == 'ecrire' ? '-prive' : '');  | 
                                                        |
| 342 | - $desc->texte = '<span '  | 
                                                        |
| 343 | - . 'lang=' . $desc->langue  | 
                                                        |
| 344 | - . ' class=' . $classe  | 
                                                        |
| 345 | -			. ' title=' . $modules . '(' . $desc->langue . ')>' | 
                                                        |
| 346 | - . $desc->texte  | 
                                                        |
| 347 | - . '</span>';  | 
                                                        |
| 348 | - $desc->texte = str_replace(  | 
                                                        |
| 349 | -			array("$desc->module:", "$desc->module|"), | 
                                                        |
| 350 | -			array("*$desc->module*:", "*$desc->module*|"), | 
                                                        |
| 351 | - $desc->texte  | 
                                                        |
| 352 | - );  | 
                                                        |
| 353 | - }  | 
                                                        |
| 354 | - return $desc;  | 
                                                        |
| 338 | +    if (!$desc->mode and $desc->texte) { | 
                                                        |
| 339 | + // ne pas modifier 2 fois l'affichage  | 
                                                        |
| 340 | + $desc->mode = 'traduction';  | 
                                                        |
| 341 | + $classe = 'debug-traduction' . ($desc->module == 'ecrire' ? '-prive' : '');  | 
                                                        |
| 342 | + $desc->texte = '<span '  | 
                                                        |
| 343 | + . 'lang=' . $desc->langue  | 
                                                        |
| 344 | + . ' class=' . $classe  | 
                                                        |
| 345 | +            . ' title=' . $modules . '(' . $desc->langue . ')>' | 
                                                        |
| 346 | + . $desc->texte  | 
                                                        |
| 347 | + . '</span>';  | 
                                                        |
| 348 | + $desc->texte = str_replace(  | 
                                                        |
| 349 | +            array("$desc->module:", "$desc->module|"), | 
                                                        |
| 350 | +            array("*$desc->module*:", "*$desc->module*|"), | 
                                                        |
| 351 | + $desc->texte  | 
                                                        |
| 352 | + );  | 
                                                        |
| 353 | + }  | 
                                                        |
| 354 | + return $desc;  | 
                                                        |
| 355 | 355 | }  | 
                                                        
@@ -41,7 +41,7 @@ discard block  | 
                                                    ||
| 41 | 41 | static $dirs = array();  | 
                                                        
| 42 | 42 | $liste = array();  | 
                                                        
| 43 | 43 |  	foreach (creer_chemin() as $dir) { | 
                                                        
| 44 | -		if (!isset($dirs[$a = $dir . $dirname])) { | 
                                                        |
| 44 | +		if (!isset($dirs[$a = $dir.$dirname])) { | 
                                                        |
| 45 | 45 | $dirs[$a] = (is_dir($a) || !$a);  | 
                                                        
| 46 | 46 | }  | 
                                                        
| 47 | 47 |  		if ($dirs[$a]) { | 
                                                        
@@ -67,20 +67,20 @@ discard block  | 
                                                    ||
| 67 | 67 | **/  | 
                                                        
| 68 | 68 |  function chercher_module_lang($module, $lang = '') { | 
                                                        
| 69 | 69 |  	if ($lang) { | 
                                                        
| 70 | - $lang = '_' . $lang;  | 
                                                        |
| 70 | + $lang = '_'.$lang;  | 
                                                        |
| 71 | 71 | }  | 
                                                        
| 72 | 72 | |
| 73 | 73 | // 1) dans un repertoire nomme lang/ se trouvant sur le chemin  | 
                                                        
| 74 | 74 | if ($f = ($module == 'local'  | 
                                                        
| 75 | - ? find_in_path($module . $lang . '.php', 'lang/')  | 
                                                        |
| 76 | - : find_langs_in_path($module . $lang . '.php', 'lang/'))  | 
                                                        |
| 75 | + ? find_in_path($module.$lang.'.php', 'lang/')  | 
                                                        |
| 76 | + : find_langs_in_path($module.$lang.'.php', 'lang/'))  | 
                                                        |
| 77 | 77 |  	) { | 
                                                        
| 78 | 78 | return is_array($f) ? $f : array($f);  | 
                                                        
| 79 | 79 | }  | 
                                                        
| 80 | 80 | |
| 81 | 81 | // 2) directement dans le chemin (old style, uniquement pour local)  | 
                                                        
| 82 | 82 | return (($module == 'local') or strpos($module, '/'))  | 
                                                        
| 83 | - ? (($f = find_in_path($module . $lang . '.php')) ? array($f) : false)  | 
                                                        |
| 83 | + ? (($f = find_in_path($module.$lang.'.php')) ? array($f) : false)  | 
                                                        |
| 84 | 84 | : false;  | 
                                                        
| 85 | 85 | }  | 
                                                        
| 86 | 86 | |
@@ -104,7 +104,7 @@ discard block  | 
                                                    ||
| 104 | 104 | **/  | 
                                                        
| 105 | 105 |  function charger_langue($lang, $module = 'spip') { | 
                                                        
| 106 | 106 | static $langs = array();  | 
                                                        
| 107 | - $var = 'i18n_' . $module . '_' . $lang;  | 
                                                        |
| 107 | + $var = 'i18n_'.$module.'_'.$lang;  | 
                                                        |
| 108 | 108 |  	if (!isset($langs[$lang])) { | 
                                                        
| 109 | 109 | $langs[$lang] = array();  | 
                                                        
| 110 | 110 |  		if ($lang) { | 
                                                        
@@ -119,13 +119,13 @@ discard block  | 
                                                    ||
| 119 | 119 | }  | 
                                                        
| 120 | 120 |  	foreach ($langs[$lang] as $l) { | 
                                                        
| 121 | 121 |  		if ($fichiers_lang = chercher_module_lang($module, $l)) { | 
                                                        
| 122 | - $GLOBALS['idx_lang'] = 'i18n_' . $module . '_' . $l;  | 
                                                        |
| 122 | + $GLOBALS['idx_lang'] = 'i18n_'.$module.'_'.$l;  | 
                                                        |
| 123 | 123 | include(array_shift($fichiers_lang));  | 
                                                        
| 124 | 124 | surcharger_langue($fichiers_lang);  | 
                                                        
| 125 | 125 |  			if ($l !== $lang) { | 
                                                        
| 126 | - $GLOBALS[$var] = &$GLOBALS['i18n_' . $module . '_' . $l];  | 
                                                        |
| 126 | + $GLOBALS[$var] = &$GLOBALS['i18n_'.$module.'_'.$l];  | 
                                                        |
| 127 | 127 | }  | 
                                                        
| 128 | - $GLOBALS['lang_' . $var] = $l;  | 
                                                        |
| 128 | + $GLOBALS['lang_'.$var] = $l;  | 
                                                        |
| 129 | 129 |  			#spip_log("module de langue : ${module}_$l.php", 'traduire'); | 
                                                        
| 130 | 130 | break;  | 
                                                        
| 131 | 131 | }  | 
                                                        
@@ -163,7 +163,7 @@ discard block  | 
                                                    ||
| 163 | 163 |  	foreach ($fichiers as $fichier) { | 
                                                        
| 164 | 164 |  		if (!isset($surcharges[$fichier])) { | 
                                                        
| 165 | 165 | $idx_lang_normal = $GLOBALS['idx_lang'];  | 
                                                        
| 166 | - $GLOBALS['idx_lang'] = $GLOBALS['idx_lang'] . '@temporaire';  | 
                                                        |
| 166 | + $GLOBALS['idx_lang'] = $GLOBALS['idx_lang'].'@temporaire';  | 
                                                        |
| 167 | 167 | include($fichier);  | 
                                                        
| 168 | 168 | $surcharges[$fichier] = $GLOBALS[$GLOBALS['idx_lang']];  | 
                                                        
| 169 | 169 | unset($GLOBALS[$GLOBALS['idx_lang']]);  | 
                                                        
@@ -171,7 +171,7 @@ discard block  | 
                                                    ||
| 171 | 171 | }  | 
                                                        
| 172 | 172 |  		if (is_array($surcharges[$fichier])) { | 
                                                        
| 173 | 173 | $GLOBALS[$GLOBALS['idx_lang']] = array_merge(  | 
                                                        
| 174 | - (isset($GLOBALS[$GLOBALS['idx_lang']]) ? (array)$GLOBALS[$GLOBALS['idx_lang']] : array()),  | 
                                                        |
| 174 | + (isset($GLOBALS[$GLOBALS['idx_lang']]) ? (array) $GLOBALS[$GLOBALS['idx_lang']] : array()),  | 
                                                        |
| 175 | 175 | $surcharges[$fichier]  | 
                                                        
| 176 | 176 | );  | 
                                                        
| 177 | 177 | }  | 
                                                        
@@ -249,27 +249,27 @@ discard block  | 
                                                    ||
| 249 | 249 |  	} else { | 
                                                        
| 250 | 250 |  		$modules = array('spip', 'ecrire'); | 
                                                        
| 251 | 251 | $code = $ori;  | 
                                                        
| 252 | -		$ori_complet = implode('|', $modules) . ':' . $ori; | 
                                                        |
| 252 | +		$ori_complet = implode('|', $modules).':'.$ori; | 
                                                        |
| 253 | 253 | }  | 
                                                        
| 254 | 254 | |
| 255 | 255 | $desc = new SPIP_Traductions_Description();  | 
                                                        
| 256 | 256 | |
| 257 | 257 | // parcourir tous les modules jusqu'a ce qu'on trouve  | 
                                                        
| 258 | 258 |  	foreach ($modules as $module) { | 
                                                        
| 259 | - $var = "i18n_" . $module . "_" . $lang;  | 
                                                        |
| 259 | + $var = "i18n_".$module."_".$lang;  | 
                                                        |
| 260 | 260 | |
| 261 | 261 |  		if (empty($GLOBALS[$var])) { | 
                                                        
| 262 | 262 | charger_langue($lang, $module);  | 
                                                        
| 263 | 263 | // surcharges persos -- on cherche  | 
                                                        
| 264 | 264 | // (lang/)local_xx.php et/ou (lang/)local.php ...  | 
                                                        
| 265 | -			if (!isset($local['local_' . $lang])) { | 
                                                        |
| 265 | +			if (!isset($local['local_'.$lang])) { | 
                                                        |
| 266 | 266 | // redéfinir la langue en cours pour les surcharges (chercher_langue a pu le changer)  | 
                                                        
| 267 | 267 | $GLOBALS['idx_lang'] = $var;  | 
                                                        
| 268 | 268 | // ... (lang/)local_xx.php  | 
                                                        
| 269 | -				$local['local_' . $lang] = chercher_module_lang('local', $lang); | 
                                                        |
| 269 | +				$local['local_'.$lang] = chercher_module_lang('local', $lang); | 
                                                        |
| 270 | 270 | }  | 
                                                        
| 271 | -			if ($local['local_' . $lang]) { | 
                                                        |
| 272 | - surcharger_langue($local['local_' . $lang]);  | 
                                                        |
| 271 | +			if ($local['local_'.$lang]) { | 
                                                        |
| 272 | + surcharger_langue($local['local_'.$lang]);  | 
                                                        |
| 273 | 273 | }  | 
                                                        
| 274 | 274 | // ... puis (lang/)local.php  | 
                                                        
| 275 | 275 |  			if (!isset($local['local'])) { | 
                                                        
@@ -283,8 +283,8 @@ discard block  | 
                                                    ||
| 283 | 283 |  		if (isset($GLOBALS[$var][$code])) { | 
                                                        
| 284 | 284 | $desc->code = $code;  | 
                                                        
| 285 | 285 | $desc->module = $module;  | 
                                                        
| 286 | - if (isset($GLOBALS['lang_' . $var]))  | 
                                                        |
| 287 | - $desc->langue = $GLOBALS['lang_' . $var];  | 
                                                        |
| 286 | + if (isset($GLOBALS['lang_'.$var]))  | 
                                                        |
| 287 | + $desc->langue = $GLOBALS['lang_'.$var];  | 
                                                        |
| 288 | 288 | $desc->texte = $GLOBALS[$var][$code];  | 
                                                        
| 289 | 289 | break;  | 
                                                        
| 290 | 290 | }  | 
                                                        
@@ -338,11 +338,11 @@ discard block  | 
                                                    ||
| 338 | 338 |  	if (!$desc->mode and $desc->texte) { | 
                                                        
| 339 | 339 | // ne pas modifier 2 fois l'affichage  | 
                                                        
| 340 | 340 | $desc->mode = 'traduction';  | 
                                                        
| 341 | - $classe = 'debug-traduction' . ($desc->module == 'ecrire' ? '-prive' : '');  | 
                                                        |
| 341 | + $classe = 'debug-traduction'.($desc->module == 'ecrire' ? '-prive' : '');  | 
                                                        |
| 342 | 342 | $desc->texte = '<span '  | 
                                                        
| 343 | - . 'lang=' . $desc->langue  | 
                                                        |
| 344 | - . ' class=' . $classe  | 
                                                        |
| 345 | -			. ' title=' . $modules . '(' . $desc->langue . ')>' | 
                                                        |
| 343 | + . 'lang='.$desc->langue  | 
                                                        |
| 344 | + . ' class='.$classe  | 
                                                        |
| 345 | +			. ' title='.$modules.'('.$desc->langue.')>' | 
                                                        |
| 346 | 346 | . $desc->texte  | 
                                                        
| 347 | 347 | . '</span>';  | 
                                                        
| 348 | 348 | $desc->texte = str_replace(  | 
                                                        
@@ -283,8 +283,9 @@  | 
                                                    ||
| 283 | 283 |  		if (isset($GLOBALS[$var][$code])) { | 
                                                        
| 284 | 284 | $desc->code = $code;  | 
                                                        
| 285 | 285 | $desc->module = $module;  | 
                                                        
| 286 | - if (isset($GLOBALS['lang_' . $var]))  | 
                                                        |
| 287 | - $desc->langue = $GLOBALS['lang_' . $var];  | 
                                                        |
| 286 | +			if (isset($GLOBALS['lang_' . $var])) { | 
                                                        |
| 287 | + $desc->langue = $GLOBALS['lang_' . $var];  | 
                                                        |
| 288 | + }  | 
                                                        |
| 288 | 289 | $desc->texte = $GLOBALS[$var][$code];  | 
                                                        
| 289 | 290 | break;  | 
                                                        
| 290 | 291 | }  |