Skip to content

fix: set html lang on outbound emails based on service branding#2915

Closed
smcmurtry wants to merge 3 commits into
mainfrom
fix/email-html-lang-from-branding
Closed

fix: set html lang on outbound emails based on service branding#2915
smcmurtry wants to merge 3 commits into
mainfrom
fix/email-html-lang-from-branding

Conversation

@smcmurtry

@smcmurtry smcmurtry commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary | Résumé

Pair with notification-utils PR cds-snc/notification-utils#415.

get_html_email_options now returns a lang value that is splatted into
HTMLEmailTemplate(**…):

  • "fr" when the service uses BRANDING_BOTH_FR or has
    default_branding_is_french=True and no email_branding.
  • "en" otherwise.

Existing get_html_email_options tests updated to assert the new key.
Requires notifications-utils bump that adds the lang kwarg.

Related Issues | Cartes liées

Test instructions | Instructions pour tester la modification

TBD

Release Instructions | Instructions pour le déploiement

None.

Reviewer checklist | Liste de vérification du réviseur

  • This PR does not break existing functionality.
  • This PR does not violate GCNotify's privacy policies.
  • This PR does not raise new security concerns. Refer to our GC Notify Risk Register document on our Google drive.
  • This PR does not significantly alter performance.
  • Additional required documentation resulting of these changes is covered (such as the README, setup instructions, a related ADR or the technical documentation).

⚠ If boxes cannot be checked off before merging the PR, they should be moved to the "Release Instructions" section with appropriate steps required to verify before release. For example, changes to celery code may require tests on staging to verify that performance has not been affected.

Copilot AI review requested due to automatic review settings June 16, 2026 20:06
@smcmurtry smcmurtry requested a review from jimleroyer as a code owner June 16, 2026 20:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates outbound HTML email rendering options to include an explicit lang value derived from service branding, so the HTML template can set the document language appropriately.

Changes:

  • Add lang to get_html_email_options, returning "fr" for French default branding / BRANDING_BOTH_FR, otherwise "en".
  • Update existing get_html_email_options tests to assert the new lang key for branded and default-English cases.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
app/delivery/send_to_providers.py Adds lang to the HTML email options dict that is splatted into HTMLEmailTemplate(...).
tests/app/delivery/test_send_to_providers.py Updates tests to assert lang for branding types and the default English branch.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 532 to 537
"brand_text": service.email_branding.text,
"brand_name": service.email_branding.name,
"alt_text_en": service.email_branding.alt_text_en,
"alt_text_fr": service.email_branding.alt_text_fr,
"lang": "fr" if service.email_branding.brand_type == BRANDING_BOTH_FR else "en",
}
Comment on lines 840 to 853
def test_get_html_email_renderer_with_branding_details_and_render_fip_banner_english_only(notify_db, sample_service):
sample_service.email_branding = None
notify_db.session.add_all([sample_service])
notify_db.session.commit()
options = send_to_providers.get_html_email_options(sample_service)

assert options == {
"fip_banner_english": True,
"fip_banner_french": False,
"logo_with_background_colour": False,
"alt_text_en": None,
"alt_text_fr": None,
"lang": "en",
}
@smcmurtry smcmurtry marked this pull request as draft June 18, 2026 14:56
@smcmurtry

Copy link
Copy Markdown
Contributor Author

Closing since I can't actually see this language attribute when manually testing in gmail

@smcmurtry smcmurtry closed this Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants