diff --git a/lib/SimpleSAML/Locale/Language.php b/lib/SimpleSAML/Locale/Language.php index a4f32d67cb0502a68e26e7ab90c3edf0371e190e..b280593f3aecc77cec60f988cb081e8f8e159db5 100644 --- a/lib/SimpleSAML/Locale/Language.php +++ b/lib/SimpleSAML/Locale/Language.php @@ -326,6 +326,21 @@ class Language } + /** + * Return an alias for a langcode, if any + * + * @return string The alias, or null if alias not found + */ + public function getLanguageCodeAlias($langcode) + { + if (isset($this->defaultLanguageMap[$langcode]) { + return $this->defaultLanguageMap[$langcode]; + } + // No alias found, which is fine + return null; + } + + /** * Return an indexed list of all languages available. * diff --git a/lib/SimpleSAML/Locale/Localization.php b/lib/SimpleSAML/Locale/Localization.php index 3f7a7b101f575c9059c08d5e17185fde5c2fbd3f..1fc1cb74bd4a73d4da96119ff6b908980d455fc6 100644 --- a/lib/SimpleSAML/Locale/Localization.php +++ b/lib/SimpleSAML/Locale/Localization.php @@ -137,6 +137,16 @@ class Localization return $langPath; } + // Some langcodes have aliases.. + $alias = $this->language->getLanguageCodeAlias($langcode); + if (isset($alias)) { + $langPath = $localeDir.'/'.$alias.'/LC_MESSAGES/'; + \SimpleSAML\Logger::debug("Trying langpath for alternative '$alias' as '$langPath'"); + if (is_dir($langPath) && is_readable($langPath)) { + return $langPath; + } + } + // Language not found, fall back to default $defLangcode = $this->language->getDefaultLanguage(); $langPath = $localeDir.'/'.$defLangcode.'/LC_MESSAGES/';