WT-997: l10n tech parity with Springfield (alias locales, package upgrades)#17133
Open
stevejalim wants to merge 28 commits intomozilla:mainfrom
Open
WT-997: l10n tech parity with Springfield (alias locales, package upgrades)#17133stevejalim wants to merge 28 commits intomozilla:mainfrom
stevejalim wants to merge 28 commits intomozilla:mainfrom
Conversation
…O fallback
- wagtail-localize-smartling: 0.11.0 → 0.12.1
- wagtail-localize-dashboard: 0.1.2 → 0.3.0
- Add LANG_INFO["zh-CN"] = {"fallback": ["zh-hans"]} to match Springfield,
since zh-CN is in WAGTAIL_CONTENT_LANGUAGES but had no Django fallback defined
- Remove stale comment referencing non-existent bedrock.base.apps.BaseAppConfig
Ports Springfield's alias locale mechanism to Bedrock. Alias locales transparently serve another locale's page content at their own URL prefix without redirecting (e.g. /pt-PT/some/page/ serves the pt-BR page). Three coordinated pieces: - bedrock/cms/views.py: wagtail_serve_with_locale_fallback() — intercepts requests for alias locales before Wagtail and serves the fallback locale's page. Used by both the URL catch-all and prefer_cms. - bedrock/cms/wagtail_urls.py: replaces Wagtail's catch-all serve pattern with wagtail_serve_with_locale_fallback. - bedrock/cms/migrations/0005: data migration that creates non-live Locale + root page records for pt-PT, en-GB, en-CA so Wagtail is aware of them. Supporting changes: - FALLBACK_LOCALES setting (pt-PT→pt-BR, en-GB→en-US, en-CA→en-US) - EXCLUDE_LOCALES added to WAGTAIL_LOCALIZE_SMARTLING (alias locales are not sent to Smartling as separate translation jobs) - bedrock/cms/utils.py: add find_fallback_page_for_locale() and compute_cms_page_locales() (expands language picker to include alias locales) - bedrock/cms/decorators.py: prefer_cms now calls wagtail_serve_with_locale_fallback instead of wagtail_serve directly - bedrock/cms/wagtail_hooks.py: admin badge hook marking alias locales on the Wagtail locales list page - media/js/cms/wagtailadmin-locale-badges.js: JS for the above hook
…f17) When the active locale is an alias (e.g. pt-PT → pt-BR) that has no Locale DB record or no page translation, two things were broken: 1. BedrockLocale.get_active() fell straight through to en-US instead of checking FALLBACK_LOCALES first — fixed by trying the fallback locale before giving up. 2. page.localized returned the en-US source page instead of the pt-BR translation — fixed by overriding localized on AbstractBedrockCMSPage to resolve via FALLBACK_LOCALES when the base class returns a wrong-locale result. Also adds get_active_locale_url() so that page URLs embedded in templates show the alias locale prefix (e.g. /pt-PT/...) rather than the canonical fallback prefix (/pt-BR/...) when content is being served under an alias URL.
…lidation - Add en-GB, en-CA, es-CL, es-MX, pt-PT to lazy_wagtail_langs() so Wagtail is aware of them for routing (matching Springfield's approach) - Merge FALLBACK_LOCALES into existing definition near CANONICAL_LOCALES; add es-AR, es-CL → es-ES aliases alongside pt-PT, en-GB, en-CA - Add es-CL to EXCLUDE_LOCALES (alias locale, must not get Smartling jobs) - Add es-CL to data migration 0005 so it gets a non-live locale root page - Update test assertions to reflect alias locale expansion in compute_cms_page_locales (en-US pages now include en-GB, en-CA; pt-BR pages now include pt-PT)
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #17133 +/- ##
==========================================
+ Coverage 81.76% 81.87% +0.11%
==========================================
Files 175 177 +2
Lines 9381 9538 +157
==========================================
+ Hits 7670 7809 +139
- Misses 1711 1729 +18 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
dchukhin
reviewed
Apr 13, 2026
…determine request's content_locales
…g in fallback scenarios
…f their fallback locale has content for the page
…ias locale in the settings)
…s an alias locale in the settings)
Contributor
Author
|
@dchukhin Thanks for your work on this. Just do double-check, is this good to merge? if you or @maribedran can approve it, that'd be great. I made the PR so I can't approve it |
Collaborator
|
I'd say "almost"! |
Contributor
Author
|
@dchukhin Thanks for the r+ -- i just noticed that this PR was made from my fork of bedrock - it's in sync with mozilla/bedrock but can we DM to just double-check alignment before I merge, please? |
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
Brings Bedrock's CMS l10n setup to parity with Springfield. Three areas of work:
wagtail-localize-smartling0.11.0 → 0.12.1,wagtail-localize-dashboard0.1.2 → 0.3.0LANG_INFO["zh-CN"] = {"fallback": ["zh-hans"]}to match Springfield, sincezh-CNis inWAGTAIL_CONTENT_LANGUAGESbut had no Django fallback defined/pt-PT/some/page/transparently serves thept-BRpage at that URL without redirectingAlias locales added
pt-PTpt-BRen-GBen-USen-CAen-USWhat was added / changed
New files:
bedrock/cms/views.py—wagtail_serve_with_locale_fallback()intercepts alias locale requests before Wagtail and serves the fallback locale's pagebedrock/cms/wagtail_urls.py— replaces Wagtail's catch-all serve pattern with the above viewbedrock/cms/migrations/0005_create_alias_locale_records.py— creates non-liveLocale+ root page records for the three alias localesmedia/js/cms/wagtailadmin-locale-badges.js— JS for the admin locale-list badgesModified files:
bedrock/settings/base.py—FALLBACK_LOCALESdict;EXCLUDE_LOCALESinWAGTAIL_LOCALIZE_SMARTLING;zh-CNLANG_INFO fallbackbedrock/cms/utils.py—find_fallback_page_for_locale()andcompute_cms_page_locales()(language picker includes alias locales)bedrock/cms/decorators.py—prefer_cmsnow callswagtail_serve_with_locale_fallbackinstead ofwagtail_servedirectlybedrock/urls.py— swaps in the customwagtail_urlsmodulebedrock/cms/wagtail_hooks.py— admin badge hook marking alias locales on the locales list pagebedrock/cms/models/locale.py—BedrockLocale.get_active()checksFALLBACK_LOCALESbefore falling back to en-US (fixespage.localizedresolving to en-US when alias locale has no DB record)bedrock/cms/models/base.py—AbstractBedrockCMSPage.localizedproperty resolves via fallback locale when the alias locale has no translation;get_active_locale_url()rewrites embedded page URLs to keep the alias locale prefixTest plan
pytest bedrock/cms/WAGTAIL_ENABLE_ADMIN=truept-PT,en-GB,en-CAappear with "alias →" badges next to their namespt-BR(e.g. aSimpleRichTextPageat/test-alias/)/pt-PT/test-alias/— confirm it returns 200 and renders thept-BRcontent (not a redirect, not a 404)/pt-PT/not/pt-BR//en-GB/test-alias/and/en-CA/test-alias/for a page that exists inen-US— confirm transparent servingpt-BRat apt-PTURL — confirm 404 (not a 500)pt-PT,en-GB,en-CAdo not appear as available locales in the Smartling translation job UI (EXCLUDE_LOCALES)