Update of /home/spip-cvs/spip/ecrire
In directory miel:/tmp/cvs-serv10474/ecrire
Modified Files:
inc_lang.php3
Log Message:
recherche des chaines à traduire dans les modules 'local' puis 'public' puis 'spip'. (et gestion du CACHE/lang_module_xx.php3 correspondanCt)
VS: ----------------------------------------------------------------------
Index: inc_lang.php3
RCS file: /home/spip-cvs/spip/ecrire/inc_lang.php3,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -d -r1.79 -r1.80
--- inc_lang.php3 24 Oct 2003 21:38:59 -0000 1.79
+++ inc_lang.php3 25 Oct 2003 10:43:34 -0000 1.80
@@ -38,9 +38,9 @@
function ecrire_caches_langues() {
global $cache_lang_modifs;
reset($cache_lang_modifs);
- while(list($lang, ) = each($cache_lang_modifs)) {
- ecrire_cache_lang($lang, 'spip');
- }
+ while(list($module,$cache_module) = each($cache_lang_modifs))
+ while(list($lang, ) = each($cache_module))
+ ecrire_cache_lang($lang, $module);
}
//
@@ -48,19 +48,21 @@
//
function charger_langue($lang, $module = 'spip', $forcer = false) {
global $dir_ecrire, $flag_ecrire;
+
+ $fichier_lang = 'lang/'.$module.'_'.$lang.'.php3';
+ $fichier_lang_exists = file_exists($dir_ecrire.$fichier_lang);
+
// chercher dans le fichier cache ?
- if (!$flag_ecrire) {
+ if (!$flag_ecrire AND $fichier_lang_exists) {
if (!$forcer AND @file_exists('CACHE/lang_'.$module.'_'.$lang.'.php3')
AND (@filemtime('CACHE/lang_'.$module.'_'.$lang.'.php3') > @filemtime('ecrire/lang/'.$module.'_'.$lang.'.php3'))) {
$GLOBALS['idx_lang'] = 'i18n_'.$module.'_'.$lang;
return include_local('CACHE/lang_'.$module.'_'.$lang.'.php3');
}
- else $GLOBALS['cache_lang_modifs'][$lang] = true;
+ else $GLOBALS['cache_lang_modifs'][$module][$lang] = true;
}
- $fichier_lang = 'lang/'.$module.'_'.$lang.'.php3';
-
- if (file_exists($dir_ecrire.$fichier_lang)) {
+ if ($fichier_lang_exists) {
$GLOBALS['idx_lang']='i18n_'.$module.'_'.$lang;
include_ecrire ($fichier_lang);
} else {
@@ -129,25 +131,26 @@
function traduire_chaine($code, $args) {
global $spip_lang, $flag_ecrire;
- $module = 'spip';
+ $modules = array('spip');
if (strpos($code, ':')) {
- if (ereg("^([a-z]+):(.*)$", $code, $regs)) {
- $module = $regs[1];
+ if (ereg("^([a-z/]+):(.*)$", $code, $regs)) {
+ $modules = explode("/",$regs[1]);
$code = $regs[2];
}
}
- $var = "i18n_".$module."_".$spip_lang;
- if (!$GLOBALS[$var]) charger_langue($spip_lang, $module);
- if (!$flag_ecrire) {
- global $cache_lang;
- if (!isset($GLOBALS[$var][$code])) {
- charger_langue($spip_lang, $module, $code);
+ while (!$text AND (list(,$module) = each ($modules))) {
+ $var = "i18n_".$module."_".$spip_lang;
+ if (!$GLOBALS[$var]) charger_langue($spip_lang, $module);
+ if (!$flag_ecrire) {
+ global $cache_lang;
+ if (!isset($GLOBALS[$var][$code]))
+ charger_langue($spip_lang, $module, $code);
+ if (isset($GLOBALS[$var][$code]))
+ $cache_lang[$spip_lang][$code] = 1;
}
- $cache_lang[$spip_lang][$code] = 1;
+ $text = $GLOBALS[$var][$code];
}
-
- $text = $GLOBALS[$var][$code];
if (!$args) return $text;