diff --git a/language.php b/language.php index 48dad17..5657f61 100644 --- a/language.php +++ b/language.php @@ -189,7 +189,7 @@ class language } /** This function manage the cache of $package.mo files as Apache cache them - It return the $moFile to use + It return the directory to use @param string $languageCode Language with format "fr_FR" @param string|null $package The package name of the soft ($package.mo file). "messages" by default @@ -214,13 +214,12 @@ class language $category = $this->languageCategoryText ($category); $temporaries = glob ("$repLocale/$languageCode.$codeset/$category/*-*.mo"); $moFile = "$repLocale/$languageCode.$codeset/$category/$package.mo"; + if (! file_exists ($moFile)) + return ""; $linkBase = $this->cacheDir."/".filemtime($moFile)."/"; $linkEnd = "$languageCode.$codeset/$category/$package.mo"; $link = $linkBase.$linkEnd; - if (! file_exists ($moFile)) - { - return ""; - } + clearstatcache (false, $moFile); // Manage the cache directory if (! file_exists (dirname ($link))) { @@ -235,6 +234,7 @@ class language if (! file_exists ($link) || ! is_readable ($link) || filemtime ($moFile) > filemtime ($link)) { + // Do not remove immediately the old files : they can be used by Apache $files = glob ($this->cacheDir."/*/".$linkEnd); foreach ($files as $file) { @@ -252,7 +252,6 @@ class language return $link; } } - clearstatcache (false, $moFile); return $moFile; } @@ -318,10 +317,12 @@ class language // Cache the domframework's .mo file too $dfFile = $this->languageCache ($languageCode, "domframework", LC_MESSAGES, dirname (__FILE__)."/locale"); - $this->languageActivation ($dfFile, $languageCode, LC_MESSAGES, - dirname (__FILE__)."/locale"); + $dfDir = dirname (dirname (dirname ($dfFile))); + $this->languageActivation ($dfFile, $languageCode, LC_MESSAGES, $dfDir); $languageCodeFichier = $this->languageCache ($languageCode, $package); - $this->languageActivation ($languageCodeFichier, $languageCode); + $languageCodeDir = dirname (dirname (dirname ($languageCodeFichier))); + $this->languageActivation ($languageCodeFichier, $languageCode, LC_MESSAGES, + $languageCodeDir); return $languageCode; }