Skip to content
Snippets Groups Projects
Unverified Commit 4238c9b9 authored by Jaime Pérez Crespo's avatar Jaime Pérez Crespo
Browse files

bugfix: New translations are trying to be loaded when "usenewui" is disabled.

This resolves #1009.
parent 634e7118
No related branches found
No related tags found
No related merge requests found
...@@ -56,7 +56,7 @@ class Template extends Response ...@@ -56,7 +56,7 @@ class Template extends Response
* *
* @var false|Twig_Environment * @var false|Twig_Environment
*/ */
private $twig; private $twig = false;
/** /**
* The template name. * The template name.
...@@ -130,15 +130,17 @@ class Template extends Response ...@@ -130,15 +130,17 @@ class Template extends Response
// check if we are supposed to use the new UI // check if we are supposed to use the new UI
$this->useNewUI = $this->configuration->getBoolean('usenewui', false); $this->useNewUI = $this->configuration->getBoolean('usenewui', false);
// check if we need to attach a theme controller if ($this->useNewUI) {
$controller = $this->configuration->getString('theme.controller', false); // check if we need to attach a theme controller
if ($controller && class_exists($controller) && $controller = $this->configuration->getString('theme.controller', false);
in_array('\SimpleSAML\XHTML\TemplateControllerInterface', class_implements($controller)) if ($controller && class_exists($controller) &&
) { in_array('\SimpleSAML\XHTML\TemplateControllerInterface', class_implements($controller))
$this->controller = new $controller(); ) {
} $this->controller = new $controller();
}
$this->twig = $this->setupTwig(); $this->twig = $this->setupTwig();
}
parent::__construct(); parent::__construct();
} }
...@@ -268,29 +270,21 @@ class Template extends Response ...@@ -268,29 +270,21 @@ class Template extends Response
$this->localization->addModuleDomain($this->theme['module']); $this->localization->addModuleDomain($this->theme['module']);
} }
// set up translation
$options = [ $options = [
'cache' => $cache, 'cache' => $cache,
'auto_reload' => $auto_reload, 'auto_reload' => $auto_reload,
'translation_function' => ['\SimpleSAML\Locale\Translate', 'translateSingularNativeGettext'], 'translation_function' => ['\SimpleSAML\Locale\Translate', 'translateSingularGettext'],
'translation_function_plural' => ['\SimpleSAML\Locale\Translate', 'translatePluralNativeGettext'], 'translation_function_plural' => ['\SimpleSAML\Locale\Translate', 'translatePluralGettext'],
]; ];
// set up translation
if ($this->localization->i18nBackend === \SimpleSAML\Locale\Localization::GETTEXT_I18N_BACKEND) {
$options['translation_function'] = ['\SimpleSAML\Locale\Translate', 'translateSingularGettext'];
$options['translation_function_plural'] = [
'\SimpleSAML\Locale\Translate',
'translatePluralGettext'
];
} // TODO: add a branch for the old SimpleSAMLphp backend
$twig = new Twig_Environment($loader, $options); $twig = new Twig_Environment($loader, $options);
$twig->addExtension(new Twig_Extensions_Extension_I18n()); $twig->addExtension(new Twig_Extensions_Extension_I18n());
// initialize some basic context // initialize some basic context
$langParam = $this->configuration->getString('language.parameter.name', 'language'); $langParam = $this->configuration->getString('language.parameter.name', 'language');
$twig->addGlobal('languageParameterName', $langParam); $twig->addGlobal('languageParameterName', $langParam);
$twig->addGlobal('localeBackend', $this->useNewUI ? Localization::GETTEXT_I18N_BACKEND : Localization::SSP_I18N_BACKEND); $twig->addGlobal('localeBackend', Localization::GETTEXT_I18N_BACKEND);
$twig->addGlobal('currentLanguage', $this->translator->getLanguage()->getLanguage()); $twig->addGlobal('currentLanguage', $this->translator->getLanguage()->getLanguage());
$twig->addGlobal('isRTL', false); // language RTL configuration $twig->addGlobal('isRTL', false); // language RTL configuration
if ($this->translator->getLanguage()->isLanguageRTL()) { if ($this->translator->getLanguage()->isLanguageRTL()) {
......
...@@ -3,17 +3,15 @@ ...@@ -3,17 +3,15 @@
require_once('../_include.php'); require_once('../_include.php');
// Load SimpleSAMLphp configuration // Load SimpleSAMLphp configuration
$config = \SimpleSAML\Configuration::getInstance(); $config = \SimpleSAML\Configuration::getInstance()->toArray();
$config['usenewui'] = true;
$config = \SimpleSAML\Configuration::loadFromArray($config, '[ARRAY]', 'simplesaml');
$session = \SimpleSAML\Session::getSessionFromRequest(); $session = \SimpleSAML\Session::getSessionFromRequest();
// Check if valid local session exists..
//SimpleSAML\Utils\Auth::requireAdmin();
$template = new \SimpleSAML\XHTML\Template($config, 'sandbox.php'); $template = new \SimpleSAML\XHTML\Template($config, 'sandbox.php');
$template->data['pagetitle'] = 'Sandbox'; $template->data['pagetitle'] = 'Sandbox';
$template->data['sometext'] = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur.'; $template->data['sometext'] = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur.';
$template->data['remaining'] = $session->getAuthData('admin', 'Expire') - time(); $template->data['remaining'] = $session->getAuthData('admin', 'Expire') - time();
$template->data['logout'] = null; $template->data['logout'] = null;
$template->show(); $template->send();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment