/** * @depends testWhetherSetupLocaleSetsUpTheGivenLocale */ public function testWhetherTranslatePluralReturnsTheContextForm() { Translator::setupLocale('de_DE'); $result = Translator::translatePlural('context service', 'context services', 3, 'icingatest', 'test-context'); $expected = 'context plural dienste'; $this->assertEquals($expected, $result, 'Translator::translatePlural() could not return the translated context form'); }
/** * Setup internationalization using gettext * * Uses the preferred user language or the configured default and system default, respectively. * * @return self */ protected function setupInternationalization() { parent::setupInternationalization(); if ($this->user !== null && $this->user->getPreferences() !== null && ($locale = $this->user->getPreferences()->get('app.language') !== null)) { try { Translator::setupLocale($locale); } catch (Exception $error) { Logger::warning('Cannot set locale "' . $locale . '" configured in ' . 'preferences of user "' . $this->user->getUsername() . '"'); } } return $this; }
/** * Set up internationalization using gettext * * @return $this */ protected final function setupInternationalization() { if ($this->hasLocales()) { Translator::registerDomain(Translator::DEFAULT_DOMAIN, $this->getLocaleDir()); } $locale = $this->detectLocale(); if ($locale === null) { $locale = Translator::DEFAULT_LOCALE; } try { Translator::setupLocale($locale); } catch (Exception $error) { Logger::error($error); } return $this; }
/** * Setup internationalization using gettext * * Uses the language defined in the global config or the default one * * @return self */ protected function setupInternationalization() { try { Translator::setupLocale($this->config->global !== null ? $this->config->global->get('language', Translator::DEFAULT_LOCALE) : Translator::DEFAULT_LOCALE); } catch (Exception $error) { Logger::error($error); } $localeDir = $this->getApplicationDir('locale'); if (file_exists($localeDir) && is_dir($localeDir)) { Translator::registerDomain('icinga', $localeDir); } return $this; }