diff --git a/CRM/Core/I18n.php b/CRM/Core/I18n.php index 40107e9824c0..6dfbe23b566c 100644 --- a/CRM/Core/I18n.php +++ b/CRM/Core/I18n.php @@ -649,6 +649,9 @@ public function setLocale($locale) { global $dbLocale; $dbLocale = "_{$locale}"; + // For self::getLocale() + global $tsLocale; + $tsLocale = $locale; } /** diff --git a/tests/phpunit/CRM/Core/I18n/LocaleTest.php b/tests/phpunit/CRM/Core/I18n/LocaleTest.php new file mode 100644 index 000000000000..cb1e88fb6f0c --- /dev/null +++ b/tests/phpunit/CRM/Core/I18n/LocaleTest.php @@ -0,0 +1,55 @@ +enableMultilingual(); + CRM_Core_I18n_Schema::addLocale('fr_CA', 'en_US'); + + CRM_Core_I18n::singleton()->setLocale('fr_CA'); + $locale = CRM_Core_I18n::getLocale(); + + $this->assertEquals($locale, 'fr_CA'); + } + +}