From aa24d7505b40b7b617a260c0f99a1c5c960ad678 Mon Sep 17 00:00:00 2001 From: Vangelis Pantazis Date: Sun, 16 May 2021 09:04:40 +0100 Subject: [PATCH] Separates the default language for contacts from the site language --- CRM/Admin/Form/Setting/Localization.php | 4 +++- CRM/Contact/Form/Edit/CommunicationPreferences.php | 7 +++++-- CRM/Contact/Form/Inline/CommunicationPreferences.php | 7 +++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CRM/Admin/Form/Setting/Localization.php b/CRM/Admin/Form/Setting/Localization.php index 037e3aee6a..53a26fe99b 100644 --- a/CRM/Admin/Form/Setting/Localization.php +++ b/CRM/Admin/Form/Setting/Localization.php @@ -354,11 +354,13 @@ class CRM_Admin_Form_Setting_Localization extends CRM_Admin_Form_Setting { * @return array */ public static function getDefaultLanguageOptions() { - return [ + $availableOptions = [ '*default*' => ts('Use default site language'), 'undefined' => ts('Leave undefined'), 'current_site_language' => ts('Use language in use at the time'), ]; + $availableLanguages = array_merge($availableOptions, CRM_Admin_Form_Setting_Localization::getDefaultLocaleOptions()); + return $availableLanguages; } } diff --git a/CRM/Contact/Form/Edit/CommunicationPreferences.php b/CRM/Contact/Form/Edit/CommunicationPreferences.php index 007522afbf..b5c9def4b5 100644 --- a/CRM/Contact/Form/Edit/CommunicationPreferences.php +++ b/CRM/Contact/Form/Edit/CommunicationPreferences.php @@ -144,8 +144,11 @@ class CRM_Contact_Form_Edit_CommunicationPreferences { // CRM-7119: set preferred_language to default if unset if (empty($defaults['preferred_language'])) { - $config = CRM_Core_Config::singleton(); - $defaults['preferred_language'] = $config->lcMessages; + if ($form->_action == CRM_Core_Action::ADD) { + if (($defContactLanguage = CRM_Core_I18n::getContactDefaultLanguage()) != FALSE) { + $defaults['preferred_language'] = $defContactLanguage; + } + } } if (empty($defaults['communication_style_id'])) { diff --git a/CRM/Contact/Form/Inline/CommunicationPreferences.php b/CRM/Contact/Form/Inline/CommunicationPreferences.php index c53d75ef57..262cf491dc 100644 --- a/CRM/Contact/Form/Inline/CommunicationPreferences.php +++ b/CRM/Contact/Form/Inline/CommunicationPreferences.php @@ -44,8 +44,11 @@ class CRM_Contact_Form_Inline_CommunicationPreferences extends CRM_Contact_Form_ // CRM-7119: set preferred_language to default if unset if (empty($defaults['preferred_language'])) { - $config = CRM_Core_Config::singleton(); - $defaults['preferred_language'] = $config->lcMessages; + if ($form->_action == CRM_Core_Action::ADD) { + if (($defContactLanguage = CRM_Core_I18n::getContactDefaultLanguage()) != FALSE) { + $defaults['preferred_language'] = $defContactLanguage; + } + } } // CRM-19135: where CRM_Core_BAO_Contact::getValues() set label as a default value instead of reserved 'value', -- 2.25.1