Skip to content

web/i18n, core: Persist locale in a cookie and reload to switch - #25156

Merged
GirlBossRush merged 4 commits into
mainfrom
web/locale-cookie-reload
Oct 2, 2026
Merged

GirlBossRush merged 4 commits into
mainfrom
web/locale-cookie-reload

Conversation

@GirlBossRush

@GirlBossRush GirlBossRush commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Details

Locale becomes fixed for the lifetime of a page. Instead of swapping the language live in JS (the source of mixed client/server language state — #18179 / #22954), every locale-change path now persists the preference to the Django language cookie (authentik_language, which LocaleMiddleware already reads) and reloads, so the server re-renders every string — including server-rendered flow challenges — in the new locale.

Change

  • persist.ts: persistLocale / applyLocaleChange write the authentik_language cookie + reload.
  • Switch the flow locale selector, the user-settings prompt stage, and SessionContextController's post-render locale application off live setLocale.
  • Delete the sessionStorage["authentik:locale"] path and drop it from autoDetectLanguage; the server-resolved hint (window.authentik.locale) is now authoritative.
  • InterfaceView.dispatch honors ?locale= server-side, validated via check_for_language (forces TemplateResponse.render() inside the override, since it renders lazily).

Tests

  • Colocated web unit test for the cookie helper.
  • Python test for the server-side ?locale= override (applied when valid, ignored when not).

@netlify

netlify Bot commented Aug 17, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-storybook ready!

Name Link
🔨 Latest commit 346be9a
🔍 Latest deploy log https://app.netlify.com/projects/authentik-storybook/deploys/6abef48e6aab9f0008f87fc4
😎 Deploy Preview https://deploy-preview-25156--authentik-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Aug 17, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-integrations ready!

Name Link
🔨 Latest commit 352cda6
🔍 Latest deploy log https://app.netlify.com/projects/authentik-integrations/deploys/6a87bc9a1956a4000886414a
😎 Deploy Preview https://deploy-preview-25156--authentik-integrations.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Aug 17, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-docs ready!

Name Link
🔨 Latest commit 352cda6
🔍 Latest deploy log https://app.netlify.com/projects/authentik-docs/deploys/6a87bc9ab49b32000819f4dd
😎 Deploy Preview https://deploy-preview-25156--authentik-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@GirlBossRush
GirlBossRush force-pushed the web/locale-cookie-reload branch from ef08347 to 36b0733 Compare August 18, 2026 13:55
@GirlBossRush
GirlBossRush marked this pull request as ready for review August 18, 2026 13:55
@GirlBossRush
GirlBossRush requested review from a team as code owners August 18, 2026 13:55
@GirlBossRush GirlBossRush changed the title web: persist locale in a cookie and reload to switch web/i18n, core: Persist locale in a cookie and reload to switch Aug 18, 2026
@codecov

codecov Bot commented Aug 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.29%. Comparing base (6d3d6e6) to head (6d5e954).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #25156   +/-   ##
=======================================
  Coverage   92.29%   92.29%           
=======================================
  Files        1173     1174    +1     
  Lines       77508    77544   +36     
  Branches     4129     4129           
=======================================
+ Hits        71534    71571   +37     
+ Misses       5908     5907    -1     
  Partials       66       66           
Flag Coverage Δ
conformance 32.97% <21.62%> (-0.01%) ⬇️
e2e 37.78% <21.62%> (-0.01%) ⬇️
integration 29.76% <13.51%> (-0.01%) ⬇️
rust 46.45% <ø> (ø)
unit 93.71% <100.00%> (+<0.01%) ⬆️
unit-migrate 93.71% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

Comment thread authentik/core/views/interface.py Resolved
Base automatically changed from core/user-locale-precedence to main August 21, 2026 02:48
@GirlBossRush
GirlBossRush force-pushed the web/locale-cookie-reload branch 2 times, most recently from 7aa4517 to b79a58e Compare August 21, 2026 03:09
@GirlBossRush
GirlBossRush requested a review from BeryJu August 21, 2026 15:30
@github-actions

Copy link
Copy Markdown
Contributor

authentik PR Installation instructions

Instructions for docker-compose

Add the following block to your .env file:

AUTHENTIK_IMAGE=ghcr.io/goauthentik/dev-server
AUTHENTIK_TAG=gh-b79a58e6407f826c4183ea2588d8995166dd5f5d
AUTHENTIK_OUTPOSTS__CONTAINER_IMAGE_BASE=ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s

Afterwards, run the upgrade commands from the latest release notes.

Instructions for Kubernetes

Add the following block to your values.yml file:

authentik:
    outposts:
        container_image_base: ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s
global:
    image:
        repository: ghcr.io/goauthentik/dev-server
        tag: gh-b79a58e6407f826c4183ea2588d8995166dd5f5d

Afterwards, run the upgrade commands from the latest release notes.

@GirlBossRush GirlBossRush self-assigned this Aug 24, 2026
@GirlBossRush GirlBossRush added area:frontend Features or issues related to the browser, TypeScript, Node.js, etc area:backend i18n Internationalization and localization labels Aug 24, 2026
@GirlBossRush GirlBossRush moved this from Todo to In Progress in authentik Core Aug 26, 2026
@GirlBossRush
GirlBossRush force-pushed the web/locale-cookie-reload branch 2 times, most recently from a44cf43 to 7643eab Compare September 9, 2026 16:08
@GirlBossRush
GirlBossRush force-pushed the web/locale-cookie-reload branch from 7643eab to 5b166d7 Compare October 1, 2026 13:38
@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Playwright e2e

Download this run's HTML report and traces, then open the report:

gh run download 36944189187 -D playwright-artifacts
npx playwright show-report playwright-artifacts/playwright-report

Installation instructions

Instructions for docker-compose

Add the following block to your .env file:

AUTHENTIK_IMAGE=ghcr.io/goauthentik/dev-server
AUTHENTIK_TAG=gh-6d5e954ddc843bfb3ffcd880bf09da47e3f9969b
AUTHENTIK_OUTPOSTS__CONTAINER_IMAGE_BASE=ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s

Afterwards, run the upgrade commands from the latest release notes.

Instructions for Kubernetes

Add the following block to your values.yml file:

authentik:
    outposts:
        container_image_base: ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s
global:
    image:
        repository: ghcr.io/goauthentik/dev-server
        tag: gh-6d5e954ddc843bfb3ffcd880bf09da47e3f9969b

Afterwards, run the upgrade commands from the latest release notes.

@GirlBossRush
GirlBossRush force-pushed the web/locale-cookie-reload branch 2 times, most recently from c078199 to 808a941 Compare October 1, 2026 23:13
The @vendor-network tests load CAPTCHA widgets from the vendors' servers,
which CI can't rely on reaching. They fail on nearly every run and use up
the five-failure budget before other tests get to run. Skip them when CI is
set; they still run locally.
@GirlBossRush
GirlBossRush force-pushed the web/locale-cookie-reload branch from 808a941 to 464bc52 Compare October 1, 2026 23:33
GirlBossRush and others added 3 commits October 2, 2026 01:04
The ak-mdx link test expected relative docs links to resolve to
next.goauthentik.io. That's only the pre-release docs host: a build with
GIT_BUILD_HASH set, like the CI image, resolves them to the versioned host
(version-<major>-<minor>.goauthentik.io). So the test failed whenever it ran
in CI, and only looked intermittent because CI stops after five failures and
the vendor CAPTCHA tests often used those up first. Accept either host.

The application wizard's provider step now settles its fields before moving
on, so the test's next "Next" click could land on that step's button again
and leave the wizard short of the review step. Wait for the bindings step to
show before continuing.
Locale becomes fixed for the lifetime of a page: instead of switching live
in JavaScript, every locale-change path now persists the preference to the
Django language cookie (which LocaleMiddleware already reads) and reloads,
so the server re-renders every string — including server-rendered flow
challenges — in the new locale. This structurally rules out the mixed
client/server language state behind #18179 / #22954.

- add persistLocale/applyLocaleChange helpers backed by the authentik_language
  cookie; switch the flow locale selector, the user-settings prompt stage, and
  the session controller's post-render locale application to persist + reload
- drop the sessionStorage['authentik:locale'] path and remove it from
  autoDetectLanguage; the server-resolved hint (window.authentik.locale) is now
  authoritative, with navigator.languages only relevant on a first anonymous visit
- honor ?locale= server-side in LocaleOverrideMiddleware (validated via
  check_for_language) so the shell and the web UI, which read the same parameter,
  cannot disagree. It sits directly after ImpersonateMiddleware, which wraps the
  rest of the chain in the user's saved locale, so an explicit override wins
- unit-test the cookie helper; test the server-side ?locale= override

Live-switching machinery (LocaleContextController observer, msg() thunks) is
removed separately in a follow-up.

Co-authored-by: Playpen Agent <[email protected]>
@GirlBossRush
GirlBossRush force-pushed the web/locale-cookie-reload branch from 346be9a to 6d5e954 Compare October 2, 2026 00:05
@GirlBossRush
GirlBossRush merged commit 5130e75 into main Oct 2, 2026
145 checks passed
@GirlBossRush
GirlBossRush deleted the web/locale-cookie-reload branch October 2, 2026 00:27
@dominic-r dominic-r mentioned this pull request Nov 4, 2026
GirlBossRush added a commit that referenced this pull request Nov 4, 2026
The locale is fixed per page since #25156, but the catalog still loaded
from a component lifecycle hook, after every statically imported module
had evaluated. Module-level msg() calls returned English.

- each entrypoint awaits initializeLocale() before importing the interface
- the lit-localize runtime moves to #common/ui/locale/runtime
GirlBossRush added a commit that referenced this pull request Nov 6, 2026
…#27618)

* web: move entrypoint bodies into importable modules

Entrypoints import the moved module, with no change in behavior. This
lets a later change run code before the interface modules evaluate.

* web/i18n: load the locale catalog before the interface boots

The locale is fixed per page since #25156, but the catalog still loaded
from a component lifecycle hook, after every statically imported module
had evaluated. Module-level msg() calls returned English.

- each entrypoint awaits initializeLocale() before importing the interface
- the lit-localize runtime moves to #common/ui/locale/runtime

* web/i18n: remove live locale switching

Switching locale reloads the page since #25156, and the catalog now loads
before boot, so nothing observes a locale change after startup.

- LocaleContextController only provides the runtime; drop the lang observer
- drop the activeLanguageTag setter from WithLocale
- drop LOCALE_STATUS_EVENT listeners in the admin interface, API locale
  middleware, captcha stage, and locale select

* Fix type.

* Unify types.

* web/i18n: unwrap msg() thunks in label records

The catalog now loads before any interface module evaluates, so label
records can hold translated strings directly.

- label records hold strings instead of MessageFormatter thunks
- call sites read the value instead of calling it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:backend area:frontend Features or issues related to the browser, TypeScript, Node.js, etc i18n Internationalization and localization

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants