Skip to content
Snippets Groups Projects
Commit 0de17780 authored by Hanne Moa's avatar Hanne Moa
Browse files

Handle renamed/non-standard langcodes

parent 941cd5a2
No related branches found
No related tags found
No related merge requests found
......@@ -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.
*
......
......@@ -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/';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment