X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FUtils%2FSystem%2FDrupalBase.php;h=6c1eebcd6b5351bf5eebfebdfbae4ecc4240879b;hb=bc99a11fd068eb0f44d1f2bc18413578e86b277b;hp=9be10ddef13b4500705736513fa2847af8dad011;hpb=94264777f045154d25cb107ac8f2c92da193a357;p=civicrm-core.git diff --git a/CRM/Utils/System/DrupalBase.php b/CRM/Utils/System/DrupalBase.php index 9be10ddef1..6c1eebcd6b 100644 --- a/CRM/Utils/System/DrupalBase.php +++ b/CRM/Utils/System/DrupalBase.php @@ -450,25 +450,25 @@ abstract class CRM_Utils_System_DrupalBase extends CRM_Utils_System_Base { // return CiviCRM’s xx_YY locale that either matches Drupal’s Chinese locale // (for CRM-6281), Drupal’s xx_YY or is retrieved based on Drupal’s xx // sometimes for CLI based on order called, this might not be set and/or empty - global $language; + $language = $this->getCurrentLanguage(); if (empty($language)) { return NULL; } - if ($language->language == 'zh-hans') { + if ($language == 'zh-hans') { return 'zh_CN'; } - if ($language->language == 'zh-hant') { + if ($language == 'zh-hant') { return 'zh_TW'; } - if (preg_match('/^.._..$/', $language->language)) { - return $language->language; + if (preg_match('/^.._..$/', $language)) { + return $language; } - return CRM_Core_I18n_PseudoConstant::longForShort(substr($language->language, 0, 2)); + return CRM_Core_I18n_PseudoConstant::longForShort(substr($language, 0, 2)); } /** @@ -664,4 +664,14 @@ abstract class CRM_Utils_System_DrupalBase extends CRM_Utils_System_Base { } } + /** + * Function to return current language of Drupal + * + * @return string + */ + public function getCurrentLanguage() { + global $language; + return (!empty($language->language)) ? $language->language : $language; + } + }