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

Wash config 'language.available'

parent ad34e8f3
No related branches found
No related tags found
No related merge requests found
......@@ -138,7 +138,7 @@ class Language
public function __construct(\SimpleSAML_Configuration $configuration)
{
$this->configuration = $configuration;
$this->availableLanguages = $this->configuration->getArray('language.available', array('en'));
$this->availableLanguages = $this->getInstalledLanguages();
$this->defaultLanguage = $this->configuration->getString('language.default', 'en');
$this->languageParameterName = $this->configuration->getString('language.parameter.name', 'language');
$this->customFunction = $this->configuration->getArray('language.get_language_function', null);
......@@ -152,6 +152,26 @@ class Language
}
/**
* Wash configured (available) languages against installed languages
*
* @return array The set of langauges both in 'language.available' and $this->language_names
*/
private function getInstalledLanguages()
{
$configuredAvailableLanguages = $this->configuration->getArray('language.available', array('en'));
$availableLanguages = array();
foreach ($configuredAvailableLanguages as $code) {
if (array_key_exists($code, $this->language_names) && isset($this->language_names[$code])) {
$availableLanguages[] = $code;
} else {
\SimpleSAML\Logger::error("Language \"$code\" not installed. Check config.");
}
}
return $availableLanguages;
}
/*
* Rename to non-idiosyncratic language code
*
......@@ -234,7 +254,11 @@ class Language
*/
public function getLanguageLocalizedName($code)
{
return $this->language_names[$code];
if (array_key_exists($code, $this->language_names) && isset($this->language_names[$code])) {
return $this->language_names[$code];
}
\SimpleSAML\Logger::error("Name for language \"$code\" not found. Check config.");
return null;
}
......
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