fix: thread lang attribute through HTMLEmailTemplate#415
Open
smcmurtry wants to merge 1 commit into
Open
Conversation
5 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses an accessibility issue where HTML emails were always rendered with a hardcoded <html lang="en">, causing screen readers to announce non-English email content incorrectly (WCAG 3.1.1).
Changes:
- Adds an optional
langkwarg (defaulting to"en") toHTMLEmailTemplateandEmailPreviewTemplate. - Threads
langinto the Jinja render context and updatesemail_template.jinja2to use it in the<html lang="…">attribute. - Adds tests covering default behavior, several explicit language tags (including
"und"), and a bilingual content case.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
notifications_utils/template.py |
Adds lang parameter to email template classes and passes it into Jinja render context. |
notifications_utils/jinja_templates/email/email_template.jinja2 |
Replaces hardcoded lang="en" with a templated lang value on the <html> tag. |
tests/test_template_types.py |
Adds test coverage for default and parameterized lang behaviors and bilingual content rendering. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| {% if complete_html %} | ||
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | ||
| <html lang="en"> | ||
| <html lang="{{ lang | default('en', true) }}"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary | Résumé
Hardcoded
<html lang="en">in the email template caused screen readers toannounce French and bilingual emails using English phonemes (WCAG 3.1.1 fail).
langkwarg toHTMLEmailTemplateandEmailPreviewTemplate(default
"en"), threaded intoemail_template.jinja2as<html lang="{{ lang }}">."fr","fr-CA", or"und"(for bilingual content,where
add_language_divsalready emits inline<div lang="en-ca">/<div lang="fr-ca">).a
Nonefallback, and a bilinguallang="und"case.Companion change in notification-api passes
langfromget_html_email_options.Related Issues | Cartes liées
cds-snc/notification-planning#3309
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