Skip to content

Commit

Permalink
Merge pull request #17006 from mattwire/l10nallowoverrideinherit
Browse files Browse the repository at this point in the history
Allow override of inherited CMS language when in CiviCRM
  • Loading branch information
mattwire authored May 4, 2020
2 parents c90aa71 + c6cc337 commit e7684f0
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 33 deletions.
7 changes: 0 additions & 7 deletions CRM/Admin/Form/Setting/Localization.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
3 changes: 2 additions & 1 deletion CRM/Core/BAO/ConfigSetting.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ public static function applyLocale($settings, $activatedLocales) {
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}" : '';
Expand Down
3 changes: 2 additions & 1 deletion settings/Localization.setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@
'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',
Expand Down Expand Up @@ -525,7 +526,7 @@
'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',
],
Expand Down
5 changes: 0 additions & 5 deletions templates/CRM/Admin/Form/Setting/Localization.hlp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
</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}
Expand Down
16 changes: 0 additions & 16 deletions templates/CRM/Admin/Form/Setting/Localization.js

This file was deleted.

9 changes: 6 additions & 3 deletions templates/CRM/Admin/Form/Setting/Localization.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@
</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">
Expand All @@ -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>
Expand Down

0 comments on commit e7684f0

Please sign in to comment.