diff --git a/config-templates/config.php b/config-templates/config.php index 1fa9d3b40f8d1dfd764b319413a0266452135336..09117a875692dbf102ced407c8b185d262346c51 100644 --- a/config-templates/config.php +++ b/config-templates/config.php @@ -727,17 +727,6 @@ $config = [ 'language.cookie.httponly' => false, '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(). * Function should return language code of one of the available languages or NULL. diff --git a/lib/SimpleSAML/Locale/Localization.php b/lib/SimpleSAML/Locale/Localization.php index 9a4543d37ae95fc21553d8653eaf39867440179d..66427da457578cc1cb8ea9e4f398bf0e1d3bae58 100644 --- a/lib/SimpleSAML/Locale/Localization.php +++ b/lib/SimpleSAML/Locale/Localization.php @@ -96,7 +96,7 @@ class Localization $this->localeDir = $this->configuration->resolvePath('locales'); $this->language = new Language($configuration); $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(); } diff --git a/lib/SimpleSAML/XHTML/Template.php b/lib/SimpleSAML/XHTML/Template.php index 042f068305c2a45fd88ff3f00a91a37b12049afe..903076ff67f701a2d66f6bcb691e8305fb1b69d5 100644 --- a/lib/SimpleSAML/XHTML/Template.php +++ b/lib/SimpleSAML/XHTML/Template.php @@ -12,6 +12,7 @@ namespace SimpleSAML\XHTML; use JaimePerez\TwigConfigurableI18n\Twig\Environment as Twig_Environment; use JaimePerez\TwigConfigurableI18n\Twig\Extensions\Extension\I18n as Twig_Extensions_Extension_I18n; use Symfony\Component\HttpFoundation\Response; +use SimpleSAML\Locale\Localization; class Template extends Response { @@ -265,7 +266,7 @@ class Template extends Response // initialize some basic context $langParam = $this->configuration->getString('language.parameter.name', 'language'); $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('isRTL', false); // language RTL configuration if ($this->translator->getLanguage()->isLanguageRTL()) { diff --git a/templates/sandbox.twig b/templates/sandbox.twig index 316c855cfba98e398a8237ed4dc77567505efdf5..1ff8134fd7e0a2d08a1b1be18f7623549cce2ef3 100644 --- a/templates/sandbox.twig +++ b/templates/sandbox.twig @@ -15,17 +15,6 @@ </p> <h2>Localization</h2> {% 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 language is <strong>{{ currentLanguage }}</strong>. Change to other languages to see the examples change.</p> <h4>Usage examples</h4> diff --git a/tests/lib/SimpleSAML/Locale/LocalizationTest.php b/tests/lib/SimpleSAML/Locale/LocalizationTest.php index cc58f1ebe66632efcd6ffac4b9d4ce21e5391c8a..ceeb823fba12480b83cf812efed375eee9fc3b48 100644 --- a/tests/lib/SimpleSAML/Locale/LocalizationTest.php +++ b/tests/lib/SimpleSAML/Locale/LocalizationTest.php @@ -22,7 +22,7 @@ class LocalizationTest extends TestCase { // The constructor should activate the default domain $c = Configuration::loadFromArray( - ['language.i18n.backend' => 'SimpleSAMLphp'] + ['usenewui' => false] ); $l = new Localization($c); $this->assertTrue($l->isI18NBackendDefault()); @@ -35,7 +35,7 @@ class LocalizationTest extends TestCase public function testAddDomain() { $c = Configuration::loadFromArray( - ['language.i18n.backend' => 'gettext/gettext'] + ['usenewui' => true] ); $l = new Localization($c); $newDomain = 'test'; diff --git a/tests/modules/core/lib/ControllerTest.php b/tests/modules/core/lib/ControllerTest.php index ff7c959f8555efea2b7056efcacea1d17b31ffc5..9f2edea91b9409784e2b0f97e2161d634d32fca5 100644 --- a/tests/modules/core/lib/ControllerTest.php +++ b/tests/modules/core/lib/ControllerTest.php @@ -61,7 +61,7 @@ class ControllerTest extends ClearStateTestCase [ 'baseurlpath' => 'https://example.org/simplesaml', 'module.enable' => ['exampleauth' => true], - 'language.i18n.backend' => Localization::GETTEXT_I18N_BACKEND, + 'usenewui' => true, ], '[ARRAY]', 'simplesaml' diff --git a/tests/www/TemplateTest.php b/tests/www/TemplateTest.php index 06dfe10808c2ea612f0050eeb3c20a915fd99f72..2e9e3a4f4fc2d06e7e241136ba2e170dda5695f6 100644 --- a/tests/www/TemplateTest.php +++ b/tests/www/TemplateTest.php @@ -19,7 +19,7 @@ class TemplateTest extends TestCase public function testSyntax() { $config = Configuration::loadFromArray([ - 'language.i18n.backend' => 'gettext/gettext', + 'usenewui' => true, 'module.enable' => array_fill_keys(Module::getModules(), true), ]); Configuration::setPreLoadedConfig($config);