Skip to content
Extraits de code Groupes Projets
Valider 7b0034c5 rédigé par Fil's avatar Fil
Parcourir les fichiers

surcharge moderne des fichiers de langue (Paolo, ESJ)

parent 245572fc
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -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);
......
......@@ -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();
......
......@@ -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";
}
}
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter