64 $this->localeDir = $this->configuration->resolvePath(
'locales');
65 $this->language =
new Language($configuration);
66 $this->langcode = $this->language->getPosixLanguage($this->language->getLanguage());
67 $this->i18nBackend = $this->configuration->getString(
'language.i18n.backend', self::SSP_I18N_BACKEND);
88 $localeDir = $this->configuration->resolvePath(
'modules') .
'/' .
$domain .
'/locales';
131 $langcode = explode(
'_', $this->langcode);
132 $langcode = $langcode[0];
134 $langPath =
$localeDir.
'/'.$langcode.
'/LC_MESSAGES/';
136 if (is_dir($langPath) && is_readable($langPath)) {
141 $alias = $this->language->getLanguageCodeAlias($langcode);
143 $langPath =
$localeDir.
'/'.$alias.
'/LC_MESSAGES/';
145 if (is_dir($langPath) && is_readable($langPath)) {
151 $defLangcode = $this->language->getDefaultLanguage();
152 $langPath =
$localeDir.
'/'.$defLangcode.
'/LC_MESSAGES/';
153 if (is_dir($langPath) && is_readable($langPath)) {
155 $error =
"Localization not found for langcode '$langcode' at '$langPath', falling back to langcode '".
162 $error =
"Localization directory missing/broken for langcode '$langcode' and domain '$domain'";
164 throw new \Exception($error);
174 $this->translator->register();
194 $error =
"Something went wrong when trying to get path to language file, cannot load domain '$domain'.";
196 if ($catchException) {
204 $poPath = $langPath.$poFile;
205 if (file_exists($poPath) && is_readable($poPath)) {
206 $translations = Translations::fromPoFile($poPath);
207 $this->translator->loadTranslations($translations);
209 $error =
"Localization file '$poFile' not found in '$langPath', falling back to default";
222 if ($this->i18nBackend === $this::SSP_I18N_BACKEND) {
234 if ($this->i18nBackend === self::SSP_I18N_BACKEND) {
241 $this->
addDomain($this->localeDir, self::DEFAULT_DOMAIN);
setupL10N()
Set up L18N if configured or fallback to old system.
loadGettextGettextFromPO($domain=self::DEFAULT_DOMAIN, $catchException=true)
Load translation domain from Gettext/Gettext using .po.
addDomain($localeDir, $domain)
setupTranslator()
Setup the translator.
isI18NBackendDefault()
Test to check if backend is set to default.
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
getLocaleDir()
Dump the default locale directory.
const SSP_I18N_BACKEND
Old internationalization backend included in SimpleSAMLphp.
const GETTEXT_I18N_BACKEND
An internationalization backend implemented purely in PHP.
__construct(\SimpleSAML_Configuration $configuration)
Constructor.
const DEFAULT_DOMAIN
The default gettext domain.
if($modEnd===false) $module
getRegisteredDomains()
Show which domains are registered.
getLangPath($domain=self::DEFAULT_DOMAIN)
Create styles array
The data for the language used.
getDomainLocaleDir($domain)
Get the default locale dir for a specific module aka.
addModuleDomain($module, $localeDir=null)
if(!array_key_exists('domain', $_REQUEST)) $domain