Merge pull request #15422 from artfulrobot/queue-parallel
[civicrm-core.git] / CRM / Core / I18n.php
index a033519dbe9b25f877b990b113bf63d1034030e3..b41f89c3372f95cba1d313b1abaa190e46062546 100644 (file)
@@ -611,6 +611,17 @@ class CRM_Core_I18n {
     return (in_array($short, $rtl));
   }
 
+  /**
+   * If you switch back/forth between locales/drivers, it may be necessary
+   * to reset some options.
+   */
+  protected function reactivate() {
+    if ($this->_nativegettext) {
+      $this->setNativeGettextLocale($this->locale);
+    }
+
+  }
+
   /**
    * Change the processing language without changing the current user language
    *
@@ -623,16 +634,6 @@ class CRM_Core_I18n {
     // Change the language of the CMS as well, for URLs.
     CRM_Utils_System::setUFLocale($locale);
 
-    if ($this->_nativegettext) {
-      // Native gettext has its own global flag indicating the active locale.
-      $this->setNativeGettextLocale($locale);
-    }
-    else {
-      // With phpgettext, each locale is retained as a separate instance of CRM_Core_I18n.
-      // It is sufficient to update `$tsLocale` and switch to the designated instance.
-      // Changing the locale for a live instance will actually cause problems when alternating locales.
-    }
-
     // For sql queries, if running in DB multi-lingual mode.
     global $dbLocale;
 
@@ -643,6 +644,8 @@ class CRM_Core_I18n {
     // For self::getLocale()
     global $tsLocale;
     $tsLocale = $locale;
+
+    CRM_Core_I18n::singleton()->reactivate();
   }
 
   /**