diff --git a/ecrire/config-multilang.php3 b/ecrire/config-multilang.php3 index ae8797c03eebfa6e95f119d586c2654cf8cd3f3a..755e132b291fec41c6a969116af500571afddca5 100644 --- a/ecrire/config-multilang.php3 +++ b/ecrire/config-multilang.php3 @@ -104,6 +104,7 @@ fin_cadre_couleur(); echo _T('info_multi_langues_choisies'); echo '</p>'; + init_codes_langues(); $langues = $GLOBALS['codes_langues']; $cesure = floor((count($langues) + 1) / 2); diff --git a/ecrire/inc_lang.php3 b/ecrire/inc_lang.php3 index 30c6a7de6177155105f06e546b0329855f24acda..b4c215f0ebe0807931662dbb58b492f35181ed92 100644 --- a/ecrire/inc_lang.php3 +++ b/ecrire/inc_lang.php3 @@ -8,7 +8,8 @@ define("_ECRIRE_INC_LANG", "1"); // // Charger un fichier langue // -function charger_langue($lang, $module = 'spip', $forcer = false) { + +function charger_langue($lang, $module = 'spip') { $fichier_lang = $module.'_'.$lang.'.php3'; $fichier_lang_exists = @is_readable(_DIR_LANG . $fichier_lang); @@ -35,10 +36,33 @@ function charger_langue($lang, $module = 'spip', $forcer = false) { } // surcharge perso - if ($f = (find_in_path('lang_perso.php3'))) include($f); - if ($f = (find_in_path('lang_perso_'.$lang.'.php3'))) include($f); + if ($f = (find_in_path('lang_perso.php3'))) + surcharger_langue($f); + if ($f = (find_in_path('lang_perso_'.$lang.'.php3'))) + surcharger_langue($f); + + # // Overkill ? Surcharger uniquement le module demande + # if ($f = (find_in_path('lang_perso_'.$module.'_'.$lang.'.php3'))) + # surcharger_langue($f); +} + +// +// Surcharger le fichier de langue courant avec un autre (tordu, hein...) +// +function surcharger_langue($f) { + $idx_lang_normal = $GLOBALS['idx_lang']; + $GLOBALS['idx_lang'] .= '_temporaire'; + include($f); + + foreach ($GLOBALS[$GLOBALS['idx_lang']] as $var => $val) + $GLOBALS[$idx_lang_normal][$var] = $val; + + unset ($GLOBALS[$GLOBALS['idx_lang']]); + $GLOBALS['idx_lang'] = $idx_lang_normal; } + + // // Changer la langue courante // @@ -86,7 +110,6 @@ function regler_langue_navigateur() { // function traduire_chaine($code, $args) { global $spip_lang; - global $cache_lang; // modules par defaut if (_DIR_RESTREINT) @@ -102,17 +125,12 @@ function traduire_chaine($code, $args) { } } - $text = ''; // parcourir tous les modules jusqu'a ce qu'on trouve + $text = ''; while (!$text AND (list(,$module) = each ($modules))) { $var = "i18n_".$module."_".$spip_lang; - if (empty($GLOBALS[$var])) charger_langue($spip_lang, $module); - if (_DIR_RESTREINT) { - if (!isset($GLOBALS[$var][$code])) - charger_langue($spip_lang, $module, $code); - if (isset($GLOBALS[$var][$code])) - $cache_lang[$spip_lang][$code] = 1; - } + if (empty($GLOBALS[$var])) + charger_langue($spip_lang, $module); $text = $GLOBALS[$var][$code]; } @@ -136,6 +154,7 @@ function traduire_chaine($code, $args) { function traduire_nom_langue($lang) { + init_codes_langues(); $r = $GLOBALS['codes_langues'][$lang]; if (!$r) $r = $lang; @@ -518,13 +537,11 @@ function utiliser_langue_visiteur() { // Initialisation // function init_langues() { - global $all_langs, $langue_site, $cache_lang, $cache_lang_modifs; + global $all_langs, $langue_site; global $pile_langues, $lang_typo, $lang_dir; $all_langs = lire_meta('langues_proposees'); $langue_site = lire_meta('langue_site'); - $cache_lang = array(); - $cache_lang_modifs = array(); $pile_langues = array(); $lang_typo = ''; $lang_dir = ''; @@ -556,7 +573,6 @@ function init_langues() { } } } - init_codes_langues(); } init_langues(); diff --git a/ecrire/inc_version.php3 b/ecrire/inc_version.php3 index c9a91c8393d67ba95568b10f89f5327ef83a8c07..fd486e623c794166818ab5022db78074fe71c74d 100644 --- a/ecrire/inc_version.php3 +++ b/ecrire/inc_version.php3 @@ -1131,17 +1131,22 @@ function texte_script($texte) { // find_in_path() : chercher un fichier nomme x selon le chemin rep1:rep2:rep3 // function find_in_path ($filename, $path='AUTO') { + // Chemin standard depuis l'espace public if ($path == 'AUTO') { $path = '.:squelettes:dist:formulaires'; if ($GLOBALS['dossier_squelettes']) $path = $GLOBALS['dossier_squelettes'].':'.$path; } + // Depuis l'espace prive, remonter d'un cran (a ameliorer si 'AUTO') + $racine = (_DIR_RESTREINT ? '' : '../'); + + // Parcourir le chemin foreach (split(':', $path) as $dir) { #spip_log ("test $path for $filename"); - if (@is_dir($dir) AND @file_exists("$dir/$filename")) { + if (@is_dir($dir) AND @file_exists("$racine$dir/$filename")) { #spip_log("$dir/$filename"); - return "$dir/$filename"; + return "$racine$dir/$filename"; } }