From c6cc337be915d542716038eb0e18b89d31d023da Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Mon, 6 Apr 2020 12:52:41 +0100 Subject: [PATCH] Allow override of inherited CMS language when in CiviCRM --- CRM/Admin/Form/Setting/Localization.php | 7 ------- CRM/Core/BAO/ConfigSetting.php | 3 ++- settings/Localization.setting.php | 3 ++- .../CRM/Admin/Form/Setting/Localization.hlp | 5 ----- templates/CRM/Admin/Form/Setting/Localization.js | 16 ---------------- .../CRM/Admin/Form/Setting/Localization.tpl | 9 ++++++--- 6 files changed, 10 insertions(+), 33 deletions(-) delete mode 100644 templates/CRM/Admin/Form/Setting/Localization.js diff --git a/CRM/Admin/Form/Setting/Localization.php b/CRM/Admin/Form/Setting/Localization.php index 05574ccf83..f7a8b6ea7c 100644 --- a/CRM/Admin/Form/Setting/Localization.php +++ b/CRM/Admin/Form/Setting/Localization.php @@ -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. */ diff --git a/CRM/Core/BAO/ConfigSetting.php b/CRM/Core/BAO/ConfigSetting.php index 11450b6813..c462bae664 100644 --- a/CRM/Core/BAO/ConfigSetting.php +++ b/CRM/Core/BAO/ConfigSetting.php @@ -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}" : ''; diff --git a/settings/Localization.setting.php b/settings/Localization.setting.php index d2bb11944a..9fc65ef10d 100644 --- a/settings/Localization.setting.php +++ b/settings/Localization.setting.php @@ -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', ], diff --git a/templates/CRM/Admin/Form/Setting/Localization.hlp b/templates/CRM/Admin/Form/Setting/Localization.hlp index 9f171adc74..42d93a6739 100644 --- a/templates/CRM/Admin/Form/Setting/Localization.hlp +++ b/templates/CRM/Admin/Form/Setting/Localization.hlp @@ -16,11 +16,6 @@ {ts 1='href="http://php.net/manual/en/function.money-format.php"'}For a full list of options see the php money_format documentation.{/ts} {/capture} -{htxt id="inheritLocale"} -

- {ts}If checked, CiviCRM will follow CMS language changes.{/ts} -

-{/htxt} {htxt id="defaultCurrency"}

{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 index f9eb8b9f71..0000000000 --- a/templates/CRM/Admin/Form/Setting/Localization.js +++ /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(); -}); diff --git a/templates/CRM/Admin/Form/Setting/Localization.tpl b/templates/CRM/Admin/Form/Setting/Localization.tpl index ce5c162e08..c2e8529171 100644 --- a/templates/CRM/Admin/Form/Setting/Localization.tpl +++ b/templates/CRM/Admin/Form/Setting/Localization.tpl @@ -32,8 +32,10 @@ {/if} - {$form.inheritLocale.label} {help id='inheritLocale' title=$form.inheritLocale.label} - {$form.inheritLocale.html} + {$form.inheritLocale.label} + {$form.inheritLocale.html}
+ {$settings_fields.inheritLocale.description} + {if !$form.languageLimit} @@ -44,7 +46,8 @@ {$form.contact_default_language.label} {$form.contact_default_language.html}
- {ts}Default language (if any) for contact records.{/ts} + {$settings_fields.contact_default_language.description} + {$form.defaultCurrency.label} {help id='defaultCurrency' title=$form.defaultCurrency.label} -- 2.25.1