developer.jelix.org is not used any more and exists only for history. Post new tickets on the Github account.
developer.jelix.org n'est plus utilisée, et existe uniquement pour son historique. Postez les nouveaux tickets sur le compte github.

Ticket #387: bug387.patch

File bug387.patch, 3.3 KB (added by Julien, 13 years ago)

fix by using an internal "last-chance fallback" locale, by default it is en_EN

  • lib/jelix/core/jSelector.class.php

     
    458458        }
    459459        $this->locale = $locale;
    460460        $this->charset = $charset;
    461         $this->_dirname =  'locales/' .$locale.'/';
    462461        $this->_suffix = '.'.$charset.'.properties';
    463         $this->_cacheSuffix = '.'.$charset.'.php';
    464462        $this->_compilerPath=JELIX_LIB_CORE_PATH.'jLocalesCompiler.class.php';
    465463
    466464#if ENABLE_PHP_JELIX
     
    492490            throw new jExceptionSelector('jelix~errors.selector.module.unknow', $this->toString());
    493491        }
    494492
    495         // on regarde si la locale a été redéfini
    496         $overloadedPath = JELIX_APP_VAR_PATH.'overloads/'.$this->module.'/'.$this->_dirname.$this->resource.$this->_suffix;
    497         if (is_readable ($overloadedPath)){
    498             $this->_path = $overloadedPath;
    499             $this->_where = 'overloaded/';
    500             return;
     493
     494        $availableLocales = array($this->locale);
     495        if($this->locale !== $gJConfig->locale)
     496            $availableLocales[] = $gJConfig->locale;
     497        if($this->locale !== $gJConfig->internalLocale && $gJConfig->locale !== $gJConfig->internalLocale)
     498            $availableLocales[] = $gJConfig->internalLocale;
     499
     500        foreach($availableLocales as $locale){
     501            $this->_dirname =  'locales/' .$locale.'/';
     502            $overloadedPath = JELIX_APP_VAR_PATH.'overloads/'.$this->module.'/'.$this->_dirname.$this->resource.$this->_suffix;
     503            if (is_readable ($overloadedPath)){
     504                $this->_path = $overloadedPath;
     505                $this->_where = 'overloaded/';
     506                $this->_cacheSuffix = '.'.$locale.'.'.$this->charset.'.php';
     507                break;
     508            }
     509            $path = $gJConfig->_modulesPathList[$this->module].$this->_dirname.$this->resource.$this->_suffix;
     510            if (is_readable ($path)){
     511                $this->_path = $path;
     512                $this->_where = 'modules/';
     513                $this->_cacheSuffix = '.'.$locale.'.'.$this->charset.'.php';
     514                break;
     515            }
    501516        }
    502         // et sinon, on regarde si la locale existe dans le module en question
    503         $this->_path = $gJConfig->_modulesPathList[$this->module].$this->_dirname.$this->resource.$this->_suffix;
    504 
    505         if (!is_readable ($this->_path)){
     517       
     518        if(!$this->_path){
    506519            throw new jExceptionSelector('jelix~errors.selector.invalid.target', array($this->toString(), "locale"));
    507520        }
    508         $this->_where = 'modules/';
    509521    }
    510522
    511523    protected function _createCachePath(){
  • lib/jelix/core/defaultconfig.ini.php

     
    77charset = "UTF-8"
    88timeZone = "Europe/Paris"
    99
     10; internal locale, for jelix localized errors, when no locale can be found at all 
     11; (specific (de_AT) > generic (de_DE) > default-specific (es_AR) > default generic (es_ES)). 
     12; Must be en_EN of fr_FR (one the the native jelix generic locales)
     13internalLocale = en_EN
     14
    1015checkTrustedModules = off
    1116
    1217; list of modules : module,module,module