Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separates the default language for contacts from the site language #20214

Merged
merged 1 commit into from
May 17, 2021

Conversation

VangelisP
Copy link
Contributor

Overview

This is a PR related to the issue 2584

Before

Default language for contacts had 3 options:

  • Use default site language
  • Leave undefined
  • Use language in use at the time

multil01

After

Default language for contacts renders the 3 options above plus all the available languages.

multil02

Technical Details

This PR adds the new languages to the selector and then on the CommunicationPreferences.php field examines what is the value of the configuration.

This works properly via the APIv3 as well.

@civibot
Copy link

civibot bot commented May 3, 2021

(Standard links)

@civibot civibot bot added the master label May 3, 2021
@eileenmcnaughton
Copy link
Contributor

@mlutfy can you check this one?

CRM/Core/I18n.php Outdated Show resolved Hide resolved
@mlutfy
Copy link
Member

mlutfy commented May 3, 2021

Makes sense. Only minor review items on the code comments.

@VangelisP
Copy link
Contributor Author

Thanks @mlutfy , I'll sort this out tomorrow!

@VangelisP
Copy link
Contributor Author

If you think that the fixes are good to go, I can squash the 2 commits and force-push it.

@mlutfy
Copy link
Member

mlutfy commented May 5, 2021

Thank you @VangelisP, looks good to me!

I will leave open a few days to see if @bjendres has any feedback.

@mlutfy mlutfy added the merge ready PR will be merged after a few days if there are no objections label May 5, 2021
@bjendres
Copy link
Contributor

Thank you @VangelisP, looks good to me!
I will leave open a few days to see if @bjendres has any feedback.

Looks like a thorough job to me, I don't have anything to add at this point :-)

@VangelisP
Copy link
Contributor Author

VangelisP commented May 11, 2021

Recapping what we got so far:

  1. The admin interface will be rendering the previous 3 options plus (addition) all the available languages
  2. We stick with the $availableLanguages = array_merge($availableOptions, CRM_Admin_Form_Setting_Localization::getDefaultLocaleOptions()); way to render the list
  3. We prepopulate the field with the stored options only if the contact is new by adding a new conditional check on CRM-7119 for both edit and inline edit modes.

If we are happy, let me know and I can squash the commits into 1.

@eileenmcnaughton
Copy link
Contributor

This looks correct to me know (squishing aside)

@eileenmcnaughton
Copy link
Contributor

Actually I think this can be simplified further - I don't think we need to fall back to

 else {
          $config = CRM_Core_Config::singleton();
          $defaults['preferred_language'] = $config->lcMessages;
        }

because that would already have been returned from getContactDefaultLanguage if appropriate

@VangelisP
Copy link
Contributor Author

You are right, this is being returned from getContactDefaultLanguage(), adjusting my code accordingly.

Thanks !

@eileenmcnaughton
Copy link
Contributor

Yay

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
master merge ready PR will be merged after a few days if there are no objections
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants