Commit 5b41b8bf authored by Côme Chilliet's avatar Côme Chilliet
Browse files

Merge branch '6051-check-locale-availability-upon-configuration-save' into '1.4-dev'

Resolve "Check locale availability upon configuration save"

See merge request fusiondirectory/fd!715
Showing with 23 additions and 0 deletions
+23 -0
......@@ -127,6 +127,26 @@ class Language
return al2gt($langs);
}
/*!
* \brief Checks if a locale is available
*
* \param string $lang Language locale to use
*/
public static function isAvailable (string $lang): bool
{
/* Store current locale */
$locale = setlocale(LC_ALL, 0);
/* Try to switch */
list ($language, , $char) = parse_gettext_lang($lang);
$langset = setlocale(LC_ALL, $lang, $language.'.'.$char);
/* Set current locale back */
setlocale(LC_ALL, $locale);
return ($langset !== FALSE);
}
/*!
* \brief Get the language for the user connecting
*
......
......@@ -533,6 +533,9 @@ class configInLdap extends simplePlugin
if (($this->fdPasswordDefaultHash == 'sasl') && ($this->fdSaslRealm == '') && ($this->fdSaslExop == '')) {
$messages[] = _('You need to fill saslRealm or saslExop in the configuration screen in order to use SASL');
}
if ($this->attributesAccess['fdLanguage']->hasChanged() && ($this->fdLanguage != '') && !Language::isAvailable($this->fdLanguage)) {
$messages[] = sprintf(_('It seems the selected language "%s" is not installed on the system. Please install it or select an other one.'), $this->fdLanguage);
}
return $messages;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment