// Compute default locale.
global $language;
- $model->lang = \Civi\Setup\LocaleUtil::pickClosest($language->langcode, $model->getField('lang', 'options'));
+ $model->lang = \Civi\Setup\LocaleUtil::pickClosest($language->langcode ?? NULL, $model->getField('lang', 'options'));
});
function _drupal_civisetup_getPublicFiles() {
* Ex: 'en_US'.
*/
public static function pickClosest($preferredLang, $availLangs, $default = 'en_US') {
+ if ($preferredLang === NULL || $preferredLang === '') {
+ return $default;
+ }
+
// Perhaps we have this exact language?
if (isset($availLangs[$preferredLang])) {
return $preferredLang;