CRM-18362, additional cleanup
authorsunil <esunil.pawar@gmail.com>
Fri, 8 Apr 2016 06:15:17 +0000 (11:45 +0530)
committersunil <esunil.pawar@gmail.com>
Fri, 8 Apr 2016 06:15:17 +0000 (11:45 +0530)
CRM/Contribute/BAO/ContributionPage.php
CRM/Core/BAO/ConfigSetting.php
CRM/Core/I18n.php
CRM/Core/I18n/Form.php
CRM/Core/PseudoConstant.php
CRM/Core/Resources.php
CRM/Core/Smarty.php
Civi/API/Subscriber/I18nSubscriber.php

index 990eefb846685edb7456e0e202b0d583fd488068..beae633c7cc83a6d1e41e0804b7eddb31b7ddf8c 100644 (file)
@@ -847,7 +847,7 @@ LEFT JOIN  civicrm_premiums            ON ( civicrm_premiums.entity_id = civicrm
    * @return array|string
    */
   public static function formatModuleData($params, $setDefault = FALSE, $module) {
-    global $tsLocale;
+    $tsLocale = CRM_Core_I18n::getLocale();
     $config = CRM_Core_Config::singleton();
     $json = $jsonDecode = NULL;
     $domain = new CRM_Core_DAO_Domain();
index e2a708c3dc74c1c089a0a554c05bb93e6a22c5b4..39506c65b72534c124ee956b86714fb114131ff7 100644 (file)
@@ -212,8 +212,7 @@ class CRM_Core_BAO_ConfigSetting {
     $dbLocale = $multiLang ? "_{$chosenLocale}" : '';
 
     // FIXME: an ugly hack to fix CRM-4041
-    global $tsLocale;
-    $tsLocale = $chosenLocale;
+    CRM_Core_I18n::setLocale($chosenLocale);
 
     // FIXME: as bad aplace as any to fix CRM-5428
     // (to be moved to a sane location along with the above)
index 94d8ed6272b1be430fb6aef5738a488ce2d8ed6b..5396e9e19ceaec7b4cdc0b4bdea3c54235f47cc8 100644 (file)
@@ -441,7 +441,7 @@ class CRM_Core_I18n {
     &$array,
     $params = array()
   ) {
-    global $tsLocale;
+    $tsLocale = CRM_Core_I18n::getLocale();
 
     if ($tsLocale == 'en_US') {
       return;
@@ -615,7 +615,7 @@ class CRM_Core_I18n {
   public static function &singleton() {
     static $singleton = array();
 
-    global $tsLocale;
+    $tsLocale = CRM_Core_I18n::getLocale();
     if (!isset($singleton[$tsLocale])) {
       $singleton[$tsLocale] = new CRM_Core_I18n($tsLocale);
     }
@@ -632,7 +632,7 @@ class CRM_Core_I18n {
   public static function setLcTime() {
     static $locales = array();
 
-    global $tsLocale;
+    $tsLocale = CRM_Core_I18n::getLocale();
     if (!isset($locales[$tsLocale])) {
       // with the config being set to pl_PL: try pl_PL.UTF-8,
       // then pl_PL, if neither present fall back to C
@@ -663,8 +663,7 @@ class CRM_Core_I18n {
       ));
     }
     elseif ($language == 'current_site_language') {
-      global $tsLocale;
-      return $tsLocale;
+      return CRM_Core_I18n::getLocale();
     }
 
     return $language;
@@ -680,6 +679,15 @@ class CRM_Core_I18n {
     return $tsLocale;
   }
 
+  /**
+   * Set the current locale
+   * @param $locale
+   */
+  public static function setLocale($locale) {
+    global $tsLocale;
+    $tsLocale = $locale;
+  }
+
 }
 
 /**
@@ -707,7 +715,7 @@ function ts($text, $params = array()) {
     $config = CRM_Core_Config::singleton();
   }
 
-  global $tsLocale;
+  $tsLocale = CRM_Core_I18n::getLocale();
   if (!$i18n or $locale != $tsLocale) {
     $i18n = CRM_Core_I18n::singleton();
     $locale = $tsLocale;
index 6cbb7859edc2e4ca40135f5824fabec29fa03e74..f2fa0a5838ee41c14b07c59cd5f3e496d6717c05 100644 (file)
@@ -35,7 +35,7 @@
 class CRM_Core_I18n_Form extends CRM_Core_Form {
   public function buildQuickForm() {
     $config = CRM_Core_Config::singleton();
-    global $tsLocale;
+    $tsLocale = CRM_Core_I18n::getLocale();
     $this->_locales = array_keys($config->languageLimit);
 
     // get the part of the database we want to edit and validate it
index be78d7111f4fef7bdd6fee8e6af6039c6b0bd558..dc737bb721d8d3122408d06378eb212fd395e7db 100644 (file)
@@ -706,7 +706,7 @@ class CRM_Core_PseudoConstant {
       self::populate(self::$stateProvince, 'CRM_Core_DAO_StateProvince', TRUE, 'name', 'is_active', $whereClause);
 
       // localise the province names if in an non-en_US locale
-      global $tsLocale;
+      $tsLocale = CRM_Core_I18n::getLocale();
       if ($tsLocale != '' and $tsLocale != 'en_US') {
         $i18n = CRM_Core_I18n::singleton();
         $i18n->localizeArray(self::$stateProvince, array(
@@ -837,7 +837,7 @@ WHERE  id = %1";
       }
 
       // localise the country names if in an non-en_US locale
-      global $tsLocale;
+      $tsLocale = CRM_Core_I18n::getLocale();
       if ($tsLocale != '' and $tsLocale != 'en_US') {
         $i18n = CRM_Core_I18n::singleton();
         $i18n->localizeArray(self::$country, array(
@@ -1565,7 +1565,7 @@ ORDER BY name";
 
     // localise the stateProvince names if in an non-en_US locale
     $config = CRM_Core_Config::singleton();
-    global $tsLocale;
+    $tsLocale = CRM_Core_I18n::getLocale();
     if ($tsLocale != '' and $tsLocale != 'en_US') {
       $i18n = CRM_Core_I18n::singleton();
       $i18n->localizeArray($result, array(
index 83cb73686e9779d230ca2112c82dbb5127373922..67ec542aa7d48b500c933497307379ede38a8493 100644 (file)
@@ -603,7 +603,7 @@ class CRM_Core_Resources {
         }
       }
 
-      global $tsLocale;
+      $tsLocale = CRM_Core_I18n::getLocale();
       // Dynamic localization script
       $this->addScriptUrl(CRM_Utils_System::url('civicrm/ajax/l10n-js/' . $tsLocale, array('r' => $this->getCacheCode())), $jsWeight++, $region);
 
@@ -753,7 +753,7 @@ class CRM_Core_Resources {
       $items[] = "js/crm.optionEdit.js";
     }
 
-    global $tsLocale;
+    $tsLocale = CRM_Core_I18n::getLocale();
     // Add localized jQuery UI files
     if ($tsLocale && $tsLocale != 'en_US') {
       // Search for i18n file in order of specificity (try fr-CA, then fr)
index 40b2a91e85985c8cf06de3cfd7bb1b206ce38f3c..5a3cb1cfa8d7eb35ac1efd01de30fc6df50b835d 100644 (file)
@@ -146,7 +146,7 @@ class CRM_Core_Smarty extends Smarty {
     $this->assign_by_ref('config', $config);
     $this->assign_by_ref('session', $session);
 
-    global $tsLocale;
+    $tsLocale = CRM_Core_I18n::getLocale();
     $this->assign('tsLocale', $tsLocale);
 
     // CRM-7163 hack: we don’t display langSwitch on upgrades anyway
@@ -318,7 +318,7 @@ class CRM_Core_Smarty extends Smarty {
   }
 
   private function getLocale() {
-    global $tsLocale;
+    $tsLocale = CRM_Core_I18n::getLocale();
     if (!empty($tsLocale)) {
       return $tsLocale;
     }
index 11b72e9cecc656681f9e46872d18086612a20a36..b87f8fbed792edcab1eb8d7dfe0c7dbd23bac9b4 100644 (file)
@@ -102,8 +102,7 @@ class I18nSubscriber implements EventSubscriberInterface {
         $dbLocale = $multiLang && $lcMessages ? "_{$lcMessages}" : '';
 
         // FIXME: an ugly hack to fix CRM-4041
-        global $tsLocale;
-        $tsLocale = $lcMessages;
+        \CRM_Core_I18n::setLocale($lcMessages);
       }
     }
   }