78 $this->localeDir = $this->configuration->resolvePath(
'locales');
80 $this->langcode = $this->
language->getPosixLanguage($this->
language->getLanguage());
81 $this->i18nBackend = $this->configuration->getString(
'language.i18n.backend', self::SSP_I18N_BACKEND);
102 $localeDir = $this->configuration->resolvePath(
'modules') .
'/' .
$domain .
'/locales';
145 $langcode = explode(
'_', $this->langcode);
150 if (is_dir($langPath) && is_readable($langPath)) {
157 $langPath =
$localeDir.
'/'.$alias.
'/LC_MESSAGES/';
159 if (is_dir($langPath) && is_readable($langPath)) {
165 $defLangcode = $this->
language->getDefaultLanguage();
166 $langPath =
$localeDir.
'/'.$defLangcode.
'/LC_MESSAGES/';
167 if (is_dir($langPath) && is_readable($langPath)) {
169 $error =
"Localization not found for langcode '$langcode' at '$langPath', falling back to langcode '".
176 $error =
"Localization directory missing/broken for langcode '$langcode' and domain '$domain'";
178 throw new \Exception($error);
188 $this->translator->register();
208 $error =
"Something went wrong when trying to get path to language file, cannot load domain '$domain'.";
210 if ($catchException) {
218 $poPath = $langPath.$poFile;
219 if (file_exists($poPath) && is_readable($poPath)) {
220 $translations = Translations::fromPoFile($poPath);
221 $this->translator->loadTranslations($translations);
223 $error =
"Localization file '$poFile' not found in '$langPath', falling back to default";
236 if ($this->i18nBackend === $this::SSP_I18N_BACKEND) {
248 if ($this->i18nBackend === self::SSP_I18N_BACKEND) {
255 $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.
$language
Pointer to current Language.
const GETTEXT_I18N_BACKEND
An internationalization backend implemented purely in PHP.
__construct(\SimpleSAML_Configuration $configuration)
Constructor.
$translator
Pointer to currently active translator.
const DEFAULT_DOMAIN
The default gettext domain.
if($modEnd===false) $module
$localeDomainMap
Where specific domains are stored.
getRegisteredDomains()
Show which domains are registered.
getLangPath($domain=self::DEFAULT_DOMAIN)
$langcode
Language code representing the current Language.
getDomainLocaleDir($domain)
Get the default locale dir for a specific module aka.
addModuleDomain($module, $localeDir=null)
if(!array_key_exists('domain', $_REQUEST)) $domain
$i18nBackend
The language backend to use.
$localeDir
The default locale directory.