Skip to content
Snippets Groups Projects
Commit b337f143 authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

hotline #126881 : fix i18n init error

parent 0bab6005
Branches
Tags
1 merge request!3928hotline #126881 : fix i18n init error
Pipeline #12856 passed with stage
in 49 minutes and 51 seconds
- ticket #126881 : Traductions : Correction de l'activation d'une langue autre que celle par défaut dans les traitements automatisés de Bokeh.
\ No newline at end of file
......@@ -213,22 +213,33 @@ class Bokeh_Engine {
function setupLanguage() {
$langue = Class_AdminVar::getDefaultLanguage();
ZendAfi_Locale::setDefault($langue);
$default = Class_AdminVar::getDefaultLanguage();
ZendAfi_Locale::setDefault($default);
Zend_Registry::set('locale', new ZendAfi_Locale());
$translate = new ZendAfi_Translate('gettext',
LANG_DIR . $langue . '.mo',
$langue);
LANG_DIR . $default . '.mo',
$default);
$this->_setupTranslationsIn($translate, $default);
Zend_Registry::set('translate', $translate);
Zend_Validate_Abstract::setDefaultTranslator($translate);
return $this;
}
foreach (Class_AdminVar::getLanguesWithoutDefault() as $language) {
protected function _setupTranslationsIn($translate, $default) {
if (!$languages = Class_AdminVar::getLanguesWithoutDefault())
return $this;
foreach ($languages as $language) {
$filename = LANG_DIR . $language.'.mo';
if (file_exists($filename))
$translate->addTranslation($filename, $language);
}
Zend_Registry::set('translate', $translate);
Zend_Validate_Abstract::setDefaultTranslator($translate);
$translate->setLocale($default);
return $this;
}
......
<?php
/**
* Copyright (c) 2012-2021, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class BokehEngineLanguageTest extends ModelTestCase {
/** @test */
public function withManyLanguagesShouldDefaultToFr() {
Class_AdminVar::set('DEFAULT_LANGUAGE', 'fr');
Class_AdminVar::set('LANGUES', 'en;es');
$engine = (new Bokeh_Engine)->setupLanguage();
$this->assertEquals('fr', Zend_Registry::get('translate')->getLocale());
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment