Commit 98466ff9 authored by sunil's avatar sunil

CRM-18362, additional cleanup

parent 186e53b3
......@@ -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();
......
......@@ -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)
......
......@@ -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;
......
......@@ -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
......
......@@ -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(
......
......@@ -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)
......
......@@ -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;
}
......
......@@ -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);
}
}
}
......
Markdown is supported
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