Allow override of inherited CMS language when in CiviCRM
authorMatthew Wire <mjw@mjwconsult.co.uk>
Mon, 6 Apr 2020 11:52:41 +0000 (12:52 +0100)
committerMatthew Wire <mjw@mjwconsult.co.uk>
Fri, 17 Apr 2020 17:19:52 +0000 (18:19 +0100)
CRM/Admin/Form/Setting/Localization.php
CRM/Core/BAO/ConfigSetting.php
settings/Localization.setting.php
templates/CRM/Admin/Form/Setting/Localization.hlp
templates/CRM/Admin/Form/Setting/Localization.js [deleted file]
templates/CRM/Admin/Form/Setting/Localization.tpl

index 05574ccf83b411a4f5c77015c570c0bd28defd31..f7a8b6ea7c0a86ce66ac6b78db0e44c937ea7043 100644 (file)
@@ -39,13 +39,6 @@ class CRM_Admin_Form_Setting_Localization extends CRM_Admin_Form_Setting {
     'uiLanguages' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
   ];
 
-  public function preProcess() {
-    if (!CRM_Core_I18n::isMultiLingual()) {
-      CRM_Core_Resources::singleton()
-        ->addScriptFile('civicrm', 'templates/CRM/Admin/Form/Setting/Localization.js', 1, 'html-header');
-    }
-  }
-
   /**
    * Build the form object.
    */
index 11450b681342a74cdef11496eb54c9b58f8977c7..c462bae66426c3692bd8010734eee1752b5dc3b1 100644 (file)
@@ -190,7 +190,8 @@ class CRM_Core_BAO_ConfigSetting {
     global $dbLocale;
 
     // try to inherit the language from the hosting CMS
-    if ($settings->get('inheritLocale')) {
+    // If the language is specified in the session (ie. via lcMessages) we still allow it to be overridden.
+    if ($settings->get('inheritLocale') && empty($sessionLocale)) {
       // FIXME: On multilanguage installs, CRM_Utils_System::getUFLocale() in many cases returns nothing if $dbLocale is not set
       $lcMessages = $settings->get('lcMessages');
       $dbLocale = $multiLang && $lcMessages ? "_{$lcMessages}" : '';
index d2bb11944a8f6ec2f89bd4ae25703941a73d27c8..9fc65ef10db9d75c45b88a05b28413ebc9972c3b 100644 (file)
@@ -221,6 +221,7 @@ return [
     'is_domain' => 1,
     'is_contact' => 0,
     'help_text' => NULL,
+    'description' => ts('If Yes, the initial session language will be set by the CMS, which can later be changed if using the CiviCRM language switcher.'),
   ],
   'dateformatDatetime' => [
     'group_name' => 'Localization Preferences',
@@ -525,7 +526,7 @@ return [
     'title' => ts('Default Language for contacts'),
     'is_domain' => 1,
     'is_contact' => 0,
-    'description' => ts('Default language (if any) for contact records'),
+    'description' => ts('Default language (if any) for contact records.'),
     'help_text' => 'If a contact is created with no language this setting will determine the language data (if any) to save.'
     . 'You may or may not wish to make an assumption here about whether it matches the site language',
   ],
index 9f171adc74963255e04780ff60d326f96e1ad652..42d93a6739252b38f3820444fabcc1b99d1b5eec 100644 (file)
   </ul>
   {ts 1='href="http://php.net/manual/en/function.money-format.php"'}For a full list of options see the php <a %1>money_format documentation</a>.{/ts}
 {/capture}
-{htxt id="inheritLocale"}
-  <p>
-    {ts}If checked, CiviCRM will follow CMS language changes.{/ts}
-  </p>
-{/htxt}
 {htxt id="defaultCurrency"}
   <p>
     {ts}Default currency assigned to contributions and other monetary transactions.{/ts}
diff --git a/templates/CRM/Admin/Form/Setting/Localization.js b/templates/CRM/Admin/Form/Setting/Localization.js
deleted file mode 100644 (file)
index f9eb8b9..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-CRM.$(function($) {
-  $('input[name=inheritLocale]').click(function () {
-    showHideUiLanguages();
-  });
-
-  function showHideUiLanguages() {
-    var val =  $('input[name=inheritLocale]:checked').val();
-    if(val == 0) {
-      $('.crm-localization-form-block-uiLanguages').show();
-    } else {
-      $('.crm-localization-form-block-uiLanguages').hide();
-    }
-  }
-
-  showHideUiLanguages();
-});
index ce5c162e089711c5027ec354a2dfeb5d5ef015b7..c2e85291712b7bb0de115af80253d2ff7257706c 100644 (file)
              </tr>
           {/if}
             <tr class="crm-localization-form-block-inheritLocale">
-                <td class="label">{$form.inheritLocale.label} {help id='inheritLocale' title=$form.inheritLocale.label}</td>
-                <td>{$form.inheritLocale.html}</td>
+              <td class="label">{$form.inheritLocale.label}</td>
+              <td>{$form.inheritLocale.html}<br />
+                <span class="description">{$settings_fields.inheritLocale.description}</span>
+              </td>
             </tr>
           {if !$form.languageLimit}
             <tr class="crm-localization-form-block-uiLanguages">
@@ -44,7 +46,8 @@
           <tr class="crm-localization-form-contact_default_language">
             <td class="label">{$form.contact_default_language.label}</td>
             <td>{$form.contact_default_language.html}<br />
-              <span class="description">{ts}Default language (if any) for contact records.{/ts}</span></td>
+              <span class="description">{$settings_fields.contact_default_language.description}</span>
+            </td>
           </tr>
             <tr class="crm-localization-form-block-defaultCurrency">
                 <td class="label">{$form.defaultCurrency.label} {help id='defaultCurrency' title=$form.defaultCurrency.label}</td>