Add de-AT locale and fix hardcoded English text in the unsubscribe confirmation notice - #1393
Open
caichat wants to merge 1 commit into
Open
Add de-AT locale and fix hardcoded English text in the unsubscribe confirmation notice#1393caichat wants to merge 1 commit into
caichat wants to merge 1 commit into
Conversation
…nslate hardcoded strings in web-confirm-unsubscription-notice
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.
Title: Add de-AT locale and fix hardcoded English text in the unsubscribe confirmation notice
Summary
de-AT(German - Austria) as a new supported locale: registered inshared/langs.js, loaded inserver/lib/translate.js, enabled by default inconfig/default.yaml, and provided as a full translation filelocales/de-AT/common.json(currently a copy ofde-DE).server/views/subscription/web-confirm-unsubscription-notice.mjml.hbs, where the heading and body text were hardcoded in English instead of going through{{#translate}}. This affected every language, not just the new one — even a visitor with an exactde-DEmatch would have seen this page half in English.Motivation
We run Mailtrain for German-speaking (Austrian) recipients and want the public subscription/unsubscribe pages to be in German. In practice they kept rendering in English. Digging into it (see #<ISSUE_NUMBER_HERE>) turned up two separate causes:
getLangCodeFromExpressLocale()only matches a locale if it's an exact string match againstenabledLanguages. Austrian browsers commonly sendde-ATas their topAccept-Languagepreference, which never matchesde-DE, so the request silently falls back todefaultLanguage. Registeringde-ATas its own locale (rather than trying to normalize region variants down to a base language, which would be a bigger change) was the more surgical fix given the current architecture.web-confirm-unsubscription-notice.mjml.hbsnever used{{#translate}}for its main text in the first place — it was plain English baked into the template. No locale, including the already-supportedde-DE, would have translated it. Only the button label (returnToOurWebsite) was wired through the translation system. This PR wraps the two missing strings in{{#translate}}and adds the correspondingalmostFinished/weNeedToConfirmYourEmailAddressToUnsubscribekeys.What's intentionally not in this PR
de-AT→de-DE,en-GB→en-US, etc.) instead of hardcoding individual region variants. Registering languages one at a time doesn't scale, but felt like a separate, larger change to the locale-resolution logic. Filed as a follow-up in #<ISSUE_NUMBER_HERE> together with a proposal for awww.publicIgnoreBrowserLocaleoption (public pages always usedefaultLanguage, ignoring the visitor's browser, independent of the trusted/admin interface).web-subscribed-notice,web-updated-notice,web-unsubscribed-notice,web-manual-unsubscribe-notice,web-confirm-subscription-notice,web-privacy-policy-notice, ...) likely have the same hardcoded-text pattern. We only touched the one we hit in testing; happy to do a pass over the rest in a follow-up PR if that's welcome.locales/de-AT/common.jsonis a straight copy oflocales/de-DE/common.jsonplus the two new keys — i.e. machine/human-identical German, not a distinct Austrian-German translation. Treat it as "unblocks de-AT users" rather than "adds Austrian-specific wording."Testing
Accept-Language: de-ATnow resolves to thede-ATresource bundle instead of falling back toen-US.web-confirm-unsubscription-notice.mjml.hbsnow renders fully in the resolved language (previously only the button was translated).de-DE,en-US, and the other existing languages unchanged.