/** * Test SimpleSAML\Locale\Localization::activateDomain(). */ public function testAddDomain() { $c = \SimpleSAML_Configuration::loadFromArray(array('language.i18n.backend' => 'gettext/gettext')); $l = new Localization($c); $newDomain = 'test'; $newDomainLocaleDir = $l->getLocaleDir(); $l->addDomain($newDomainLocaleDir, $newDomain); $registeredDomains = $l->getRegisteredDomains(); $this->assertArrayHasKey($newDomain, $registeredDomains); $this->assertEquals($registeredDomains[$newDomain], $newDomainLocaleDir); }
/** * Setup twig. */ private function setupTwig() { $auto_reload = $this->configuration->getBoolean('template.auto_reload', true); $cache = false; if (!$auto_reload) { // Cache only used if auto_reload = false $cache = $this->configuration->getString('template.cache', $this->configuration->resolvePath('cache')); } // set up template paths $loader = $this->setupTwigTemplatepaths(); // abort if twig template does not exist if (!$loader->exists($this->twig_template)) { return false; } // load extra i18n domains if ($this->module) { $this->localization->addModuleDomain($this->module); } $options = array('cache' => $cache, 'auto_reload' => $auto_reload, 'translation_function' => array('\\SimpleSAML\\Locale\\Translate', 'translateSingularNativeGettext'), 'translation_function_plural' => array('\\SimpleSAML\\Locale\\Translate', 'translatePluralNativeGettext')); // set up translation if ($this->localization->i18nBackend === \SimpleSAML\Locale\Localization::GETTEXT_I18N_BACKEND) { $options['translation_function'] = array('\\SimpleSAML\\Locale\\Translate', 'translateSingularGettext'); $options['translation_function_plural'] = array('\\SimpleSAML\\Locale\\Translate', 'translatePluralGettext'); } // TODO: add a branch for the old SimpleSAMLphp backend $twig = new Twig_Environment($loader, $options); $twig->addExtension(new Twig_Extensions_Extension_I18n()); return $twig; }