diff --git a/include/class_Language.inc b/include/class_Language.inc index 773943771892f1ac190294bc6405a3d126661e94..c7afdb7e39fcd7580b4c3a751ee0b977c9341eb2 100644 --- a/include/class_Language.inc +++ b/include/class_Language.inc @@ -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 * diff --git a/plugins/config/class_configInLdap.inc b/plugins/config/class_configInLdap.inc index 24e784c76ccaccc62e914509d3f1441a52f4996a..1f5b5036f866e50c425ca73faa21b4f98b375bb2 100644 --- a/plugins/config/class_configInLdap.inc +++ b/plugins/config/class_configInLdap.inc @@ -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; }