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

Move hook_civicrm_translateFields from message_admin to core #24063

Merged
merged 3 commits into from
Aug 2, 2022

Conversation

eileenmcnaughton
Copy link
Contributor

Overview

Move hook_civicrm_translateFields from message_admin to core

#23844

Before

The fact that message template fields are translatable is in the message admin UI extension. However, rendering translated is core functionality (well once the rest of #23844 is merged) it will be - so the right place to define it is in core where the functionality is

After

Moved

Technical Details

This is the part of #23844 that is causing test fails so I'm separating it out - also, it should be an easy merge when tests pass

Comments

@civibot
Copy link

civibot bot commented Jul 27, 2022

(Standard links)

@eileenmcnaughton
Copy link
Contributor Author

@totten do you think this test can work in this context - or should we skip it?

@totten
Copy link
Member

totten commented Aug 2, 2022

However, rendering translated is core functionality (well once the rest of
#23844 is merged) it will be - so the right place to define it is in core
where the functionality is

I don't feel too strongly about where hook_civicrm_translateFields bit lives, but "the right place" is a bit ambiguous. My understanding is that the ability to enable/disable translation (at runtime, per entity/field, per configuration/hook/etc) was one major goal for the Translation approached (compared to existing multi-lingual, which is more static). ie Multilingual has a singular/right place (xml/schema), but Translation does not (hence a hook).

What that means is that MessageTemplate::sendTemplate() (et al) should be defined in a way that works in either configuration (ie the same code works, regardless of whether the local policy is to enable or disable translation). From that POV, the implementation of sendTemplate() (et al) should not depend on the placement of hook_civicrm_translateFields. (It will, however, depend on the support for $preferredLanguage.)

But there are a couple other POVs, ie:

  • Unit test POV: When writing a test-suite for sendTemplate(), we should have (should be able to have) test-cases for each configuration (testing sendTemplate with and without translation configured).
  • Install/setup POV: For a particular deployment, does the site-builder prefer to have translation enabled or disabled? (Do they opt-in or opt-out? How?)

I think that the placement in message_admin lined up nicely with the "Install/setup POV", but "CRM_Core_BAO_MessageTemplate" is also OK from this POV.

From discussion, it sounded like the the "Unit test POV" is where this became important -- ie in terms of writing tests, you'd rather have the presumption that all/most deployments have translation enabled. (Presumably, for test-cases with translation disabled, then you'd have to do some extra declarations in the test to opt-out.)

@totten
Copy link
Member

totten commented Aug 2, 2022

tldr: I'm OK with moving it (because I think the placement shouldn't matter too much). Just want to make sure that we're keeping that posture (it's still going to be loosely coupled in implementation, even if the default policy is shifted around a bit).

@eileenmcnaughton
Copy link
Contributor Author

Yeah I think the message_admin extension always felt actively wrong to me (as it should be just a UI) - although I could argue a new extension for translation config makes sense rather than core - hence I didn't think it made sense to bend over backwards to keep it there for tests to pass

@seamuslee001
Copy link
Contributor

Jenkins re test this please

This test should not have been passing prior to this... it needed the event fields declared as translatable
but we got away with it until we didn't
@eileenmcnaughton eileenmcnaughton merged commit a450e84 into civicrm:master Aug 2, 2022
@eileenmcnaughton eileenmcnaughton deleted the msg_breakdown branch August 2, 2022 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants