Skip to content
Snippets Groups Projects
Commit 0e4c83dd authored by Thijs Kinkhorst's avatar Thijs Kinkhorst
Browse files

Remove language.i18.backend setting; make each templating system use its own i18n backend.

Twig will always use gettext, legacy will use legacy. Twig does not
work with legacy so new ui would break if you would not also set this
option. Instead, just switch the system in use based on the usenewui
config variable.
parent 7836dd00
Branches
No related tags found
No related merge requests found
...@@ -727,17 +727,6 @@ $config = [ ...@@ -727,17 +727,6 @@ $config = [
'language.cookie.httponly' => false, 'language.cookie.httponly' => false,
'language.cookie.lifetime' => (60 * 60 * 24 * 900), 'language.cookie.lifetime' => (60 * 60 * 24 * 900),
/*
* Which i18n backend to use.
*
* "SimpleSAMLphp" is the home made system, valid for 1.x.
* For 2.x, only "gettext/gettext" will be possible.
*
* Home-made templates will always use "SimpleSAMLphp".
* To use twig (where avaliable), select "gettext/gettext".
*/
'language.i18n.backend' => 'SimpleSAMLphp',
/** /**
* Custom getLanguage function called from SimpleSAML\Locale\Language::getLanguage(). * Custom getLanguage function called from SimpleSAML\Locale\Language::getLanguage().
* Function should return language code of one of the available languages or NULL. * Function should return language code of one of the available languages or NULL.
......
...@@ -96,7 +96,7 @@ class Localization ...@@ -96,7 +96,7 @@ class Localization
$this->localeDir = $this->configuration->resolvePath('locales'); $this->localeDir = $this->configuration->resolvePath('locales');
$this->language = new Language($configuration); $this->language = new Language($configuration);
$this->langcode = $this->language->getPosixLanguage($this->language->getLanguage()); $this->langcode = $this->language->getPosixLanguage($this->language->getLanguage());
$this->i18nBackend = $this->configuration->getString('language.i18n.backend', self::SSP_I18N_BACKEND); $this->i18nBackend = ($this->configuration->getBoolean('usenewui', false) ? self::GETTEXT_I18N_BACKEND : self::SSP_I18N_BACKEND);
$this->setupL10N(); $this->setupL10N();
} }
......
...@@ -12,6 +12,7 @@ namespace SimpleSAML\XHTML; ...@@ -12,6 +12,7 @@ namespace SimpleSAML\XHTML;
use JaimePerez\TwigConfigurableI18n\Twig\Environment as Twig_Environment; use JaimePerez\TwigConfigurableI18n\Twig\Environment as Twig_Environment;
use JaimePerez\TwigConfigurableI18n\Twig\Extensions\Extension\I18n as Twig_Extensions_Extension_I18n; use JaimePerez\TwigConfigurableI18n\Twig\Extensions\Extension\I18n as Twig_Extensions_Extension_I18n;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use SimpleSAML\Locale\Localization;
class Template extends Response class Template extends Response
{ {
...@@ -265,7 +266,7 @@ class Template extends Response ...@@ -265,7 +266,7 @@ class Template extends Response
// 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->configuration->getString('language.i18n.backend', 'SimpleSAMLphp')); $twig->addGlobal('localeBackend', $this->useNewUI ? Localization::GETTEXT_I18N_BACKEND : Localization::SSP_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()) {
......
...@@ -15,17 +15,6 @@ ...@@ -15,17 +15,6 @@
</p> </p>
<h2>Localization</h2> <h2>Localization</h2>
{% set variable = 'Hello, Untranslated World!' %} {% set variable = 'Hello, Untranslated World!' %}
<p>SimpleSAMLphp lets you choose which translation backend to choose, thanks to the
<code>language.i18n.backend</code> configuration option. Two possible values are supported there:
</p>
<ul>
<li><code>SimpleSAMLphp</code>: to keep using the old SimpleSAMLphp translation system. This is the
default, and will disappear as an option in SimpleSAMLphp 2.0.</li>
<li><code>gettext/gettext</code>: to use a <em>gettext</em> implementation written entirely in PHP, allowing
you to use any locale, no matter if they are installed on the system or not.</li>
</ul>
<p>Note that <code>gettext/gettext</code> <strong>will become the default</strong> in SimpleSAMLphp 2.0.
Currently, you are using the following backend: <code>{{ localeBackend }}</code>.</p>
<p>This page is written in english only, but the examples used here are translated to several languages. The current <p>This page is written in english only, but the examples used here are translated to several languages. The current
language is <strong>{{ currentLanguage }}</strong>. Change to other languages to see the examples change.</p> language is <strong>{{ currentLanguage }}</strong>. Change to other languages to see the examples change.</p>
<h4>Usage examples</h4> <h4>Usage examples</h4>
......
...@@ -22,7 +22,7 @@ class LocalizationTest extends TestCase ...@@ -22,7 +22,7 @@ class LocalizationTest extends TestCase
{ {
// The constructor should activate the default domain // The constructor should activate the default domain
$c = Configuration::loadFromArray( $c = Configuration::loadFromArray(
['language.i18n.backend' => 'SimpleSAMLphp'] ['usenewui' => false]
); );
$l = new Localization($c); $l = new Localization($c);
$this->assertTrue($l->isI18NBackendDefault()); $this->assertTrue($l->isI18NBackendDefault());
...@@ -35,7 +35,7 @@ class LocalizationTest extends TestCase ...@@ -35,7 +35,7 @@ class LocalizationTest extends TestCase
public function testAddDomain() public function testAddDomain()
{ {
$c = Configuration::loadFromArray( $c = Configuration::loadFromArray(
['language.i18n.backend' => 'gettext/gettext'] ['usenewui' => true]
); );
$l = new Localization($c); $l = new Localization($c);
$newDomain = 'test'; $newDomain = 'test';
......
...@@ -61,7 +61,7 @@ class ControllerTest extends ClearStateTestCase ...@@ -61,7 +61,7 @@ class ControllerTest extends ClearStateTestCase
[ [
'baseurlpath' => 'https://example.org/simplesaml', 'baseurlpath' => 'https://example.org/simplesaml',
'module.enable' => ['exampleauth' => true], 'module.enable' => ['exampleauth' => true],
'language.i18n.backend' => Localization::GETTEXT_I18N_BACKEND, 'usenewui' => true,
], ],
'[ARRAY]', '[ARRAY]',
'simplesaml' 'simplesaml'
......
...@@ -19,7 +19,7 @@ class TemplateTest extends TestCase ...@@ -19,7 +19,7 @@ class TemplateTest extends TestCase
public function testSyntax() public function testSyntax()
{ {
$config = Configuration::loadFromArray([ $config = Configuration::loadFromArray([
'language.i18n.backend' => 'gettext/gettext', 'usenewui' => true,
'module.enable' => array_fill_keys(Module::getModules(), true), 'module.enable' => array_fill_keys(Module::getModules(), true),
]); ]);
Configuration::setPreLoadedConfig($config); Configuration::setPreLoadedConfig($config);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment