* @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();
$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)
&$array,
$params = array()
) {
- global $tsLocale;
+ $tsLocale = CRM_Core_I18n::getLocale();
if ($tsLocale == 'en_US') {
return;
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);
}
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
));
}
elseif ($language == 'current_site_language') {
- global $tsLocale;
- return $tsLocale;
+ return CRM_Core_I18n::getLocale();
}
return $language;
return $tsLocale;
}
+ /**
+ * Set the current locale
+ * @param $locale
+ */
+ public static function setLocale($locale) {
+ global $tsLocale;
+ $tsLocale = $locale;
+ }
+
}
/**
$config = CRM_Core_Config::singleton();
}
- global $tsLocale;
+ $tsLocale = CRM_Core_I18n::getLocale();
if (!$i18n or $locale != $tsLocale) {
$i18n = CRM_Core_I18n::singleton();
$locale = $tsLocale;
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
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(
}
// 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(
// 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(
}
}
- 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);
$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)
$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
}
private function getLocale() {
- global $tsLocale;
+ $tsLocale = CRM_Core_I18n::getLocale();
if (!empty($tsLocale)) {
return $tsLocale;
}
$dbLocale = $multiLang && $lcMessages ? "_{$lcMessages}" : '';
// FIXME: an ugly hack to fix CRM-4041
- global $tsLocale;
- $tsLocale = $lcMessages;
+ \CRM_Core_I18n::setLocale($lcMessages);
}
}
}