17143 language switcher refactor push

This commit is contained in:
2025-06-17 06:44:53 +01:00
parent 3b65133ea0
commit e2df26c935
3 changed files with 22 additions and 6 deletions
+5 -3
View File
@@ -112,9 +112,11 @@ const Header = (props) => {
.join("&")
: "";
router.push(router.pathname + queryString, undefined, {
locale: switchLocale,
});
// router.push(router.pathname + queryString, undefined, {
// locale: switchLocale,
// });
router.push(router.asPath, router.asPath, { locale: switchLocale });
};
return (
+1
View File
@@ -1,6 +1,7 @@
module.exports = {
"locales": ["en", "cy"],
"defaultLocale": "en",
"localeDetection": false,
"domains": [
{
"domain": process.env.I18N_DOMAIN,
+16 -3
View File
@@ -89,12 +89,25 @@ const authOptions = (locale, req, res) => {
"verification url API: " + url + "\n",
"============================================================\n"
);
const baseDomain = `${protocol}//${host}`;
const emailAddress = email;
const prefLang = await getPreferredLanguage(emailAddress);
const registeredPrefLanguage =
prefLang.value.length > 0
? prefLang.value[0].pinswg_preferredlanguage ===
846040000
? "cy"
: "en"
: "en";
const effectiveLocale = registeredPrefLanguage ?? locale;
let newURL =
locale == "cy"
? process.env.CY_API_ROOT +
effectiveLocale == "cy"
? baseDomain +
"/api/auth/callback/email?callbackUrl=" +
encodeURIComponent(process.env.CY_API_ROOT) +
encodeURIComponent(baseDomain + "/cy") +
"&token=" +
searchParams.get("token") +
"&email=" +