fix: DEFAULT_LOCALE is ignored on a user's first visit (#31551)

Since v0.11.4 a new visitor always got their browser's language even when an admin set DEFAULT_LOCALE, because the browser language was remembered as if the user had picked it, so the configured default never applied. The configured default now applies on the first visit again, as it did up to v0.11.3. A language the user picks in Settings and a ?lang= link still take precedence, and instances without DEFAULT_LOCALE keep following the browser language.

Fixes #31548
This commit is contained in:
Classic298 2026-09-30 17:25:16 +02:00 • committed by GitHub
parent 5338aeca89
commit 4987711391
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1269,7 +1269,10 @@
// Initialize i18n even if we didn't get a backend config,
// so `/error` can show something that's not `undefined`.
await initI18n(localStorage?.locale, backendConfig?.i18n ?? {});
await initI18n(
localStorage?.locale ?? backendConfig?.default_locale,
backendConfig?.i18n ?? {}
);
if (!localStorage.locale) {
const languages = await getLanguages();
const browserLanguages = navigator.languages