Skip to content

Commit

Permalink
Merge pull request #20214 from ixiam/dev#issue_2584
Browse files Browse the repository at this point in the history
Separates the default language for contacts from the site language
  • Loading branch information
eileenmcnaughton authored May 17, 2021
2 parents 27b1d20 + aa24d75 commit c462341
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
4 changes: 3 additions & 1 deletion CRM/Admin/Form/Setting/Localization.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,11 +354,13 @@ public static function onChangeDefaultCurrency($oldCurrency, $newCurrency, $meta
* @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;
}

}
7 changes: 5 additions & 2 deletions CRM/Contact/Form/Edit/CommunicationPreferences.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,11 @@ public static function setDefaultValues(&$form, &$defaults) {

// 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'])) {
Expand Down
7 changes: 5 additions & 2 deletions CRM/Contact/Form/Inline/CommunicationPreferences.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ public function setDefaultValues() {

// 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',
Expand Down

0 comments on commit c462341

Please sign in to comment.