mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 20:27:32 +00:00
fix(login): ensure correct i18n locale context (#10156)
This PR ensures that the correct locale context is set for the new login
This commit is contained in:
@@ -15,6 +15,21 @@ export default getRequestConfig(async () => {
|
|||||||
const _headers = await headers();
|
const _headers = await headers();
|
||||||
const { serviceUrl } = getServiceUrlFromHeaders(_headers);
|
const { serviceUrl } = getServiceUrlFromHeaders(_headers);
|
||||||
|
|
||||||
|
const languageHeader = await (await headers()).get(LANGUAGE_HEADER_NAME);
|
||||||
|
if (languageHeader) {
|
||||||
|
const headerLocale = languageHeader.split(",")[0].split("-")[0]; // Extract the language code
|
||||||
|
if (LANGS.map((l) => l.code).includes(headerLocale)) {
|
||||||
|
locale = headerLocale;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const languageCookie = cookiesList?.get(LANGUAGE_COOKIE_NAME);
|
||||||
|
if (languageCookie && languageCookie.value) {
|
||||||
|
if (LANGS.map((l) => l.code).includes(languageCookie.value)) {
|
||||||
|
locale = languageCookie.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const i18nOrganization = _headers.get("x-zitadel-i18n-organization") || ""; // You may need to set this header in middleware
|
const i18nOrganization = _headers.get("x-zitadel-i18n-organization") || ""; // You may need to set this header in middleware
|
||||||
|
|
||||||
let translations: JsonObject | {} = {};
|
let translations: JsonObject | {} = {};
|
||||||
@@ -32,21 +47,6 @@ export default getRequestConfig(async () => {
|
|||||||
console.warn("Error fetching custom translations:", error);
|
console.warn("Error fetching custom translations:", error);
|
||||||
}
|
}
|
||||||
|
|
||||||
const languageHeader = await (await headers()).get(LANGUAGE_HEADER_NAME);
|
|
||||||
if (languageHeader) {
|
|
||||||
const headerLocale = languageHeader.split(",")[0].split("-")[0]; // Extract the language code
|
|
||||||
if (LANGS.map((l) => l.code).includes(headerLocale)) {
|
|
||||||
locale = headerLocale;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const languageCookie = cookiesList?.get(LANGUAGE_COOKIE_NAME);
|
|
||||||
if (languageCookie && languageCookie.value) {
|
|
||||||
if (LANGS.map((l) => l.code).includes(languageCookie.value)) {
|
|
||||||
locale = languageCookie.value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const customMessages = translations;
|
const customMessages = translations;
|
||||||
const localeMessages = (await import(`../../locales/${locale}.json`)).default;
|
const localeMessages = (await import(`../../locales/${locale}.json`)).default;
|
||||||
const fallbackMessages = (await import(`../../locales/${fallback}.json`))
|
const fallbackMessages = (await import(`../../locales/${fallback}.json`))
|
||||||
|
Reference in New Issue
Block a user