diff --git a/frontend/messages/en.json b/frontend/messages/en.json index a58960796..ad5d8c254 100644 --- a/frontend/messages/en.json +++ b/frontend/messages/en.json @@ -979,5 +979,8 @@ "attackPath": "Attack path", "attackPaths": "Attack paths", "currentCriticality": "Current criticality", - "residualCriticality": "Residual criticality" + "residualCriticality": "Residual criticality", + "errorAssetGraphMustNotContainCycles": "The asset graph must not contain cycles.", + "resetPasswordHere": "You can reset your password here.", + "resetPassword": "Reset password" } diff --git a/frontend/messages/fr.json b/frontend/messages/fr.json index 99beff3c0..abf206708 100644 --- a/frontend/messages/fr.json +++ b/frontend/messages/fr.json @@ -903,5 +903,7 @@ "bringTheEvidencesHelpText": "Si désactivé, l'objet sera dupliqué sans ses preuves", "existingControlsHelper": "Que disposez-vous actuellement pour gérer ce risque", "extraControlsHelper": "Que ferez-vous pour atténuer ce risque", - "existingContextHelper": "Description des mesures existantes (ce champ sera bientôt obsolète)" + "existingContextHelper": "Description des mesures existantes (ce champ sera bientôt obsolète)", + "resetPasswordHere": "Vous pouvez réinitialiser votre mot de passe ici.", + "resetPassword": "Réinitialiser le mot de passe" } diff --git a/frontend/src/hooks.server.ts b/frontend/src/hooks.server.ts index cfcd9c03d..2add51d4a 100644 --- a/frontend/src/hooks.server.ts +++ b/frontend/src/hooks.server.ts @@ -4,6 +4,7 @@ import type { User } from '$lib/utils/types'; import { redirect, type Handle, type RequestEvent, type HandleFetch } from '@sveltejs/kit'; import { setFlash } from 'sveltekit-flash-message/server'; import { languageTag, setLanguageTag } from '$paraglide/runtime'; +import { DEFAULT_LANGUAGE } from '$lib/utils/constants'; import { loadFeatureFlags } from '$lib/feature-flags'; @@ -66,7 +67,7 @@ export const handle: Handle = async ({ event, resolve }) => { const errorId = new URL(event.request.url).searchParams.get('error'); if (errorId) { - setLanguageTag(event.cookies.get('ciso_lang') || 'en'); + setLanguageTag(event.cookies.get('ciso_lang') || DEFAULT_LANGUAGE); setFlash({ type: 'error', message: safeTranslate(errorId) }, event); redirect(302, '/login'); } diff --git a/frontend/src/lib/utils/constants.ts b/frontend/src/lib/utils/constants.ts index 3a4843a96..61b8706b4 100644 --- a/frontend/src/lib/utils/constants.ts +++ b/frontend/src/lib/utils/constants.ts @@ -6,6 +6,12 @@ export const BASE_API_URL = `${ : 'http://localhost:8000/api' }`; +export const DEFAULT_LANGUAGE = `${ + Object.hasOwn(env, 'PUBLIC_DEFAULT_LANGUAGE') + ? env.PUBLIC_DEFAULT_LANGUAGE + : 'en' +}`; + export const ALLAUTH_API_URL = `${BASE_API_URL}/_allauth/app/v1`; export const BACKEND_API_EXPOSED_URL = `${ diff --git a/frontend/src/routes/(app)/+layout.server.ts b/frontend/src/routes/(app)/+layout.server.ts index 9c3ee0634..42dece87a 100644 --- a/frontend/src/routes/(app)/+layout.server.ts +++ b/frontend/src/routes/(app)/+layout.server.ts @@ -1,7 +1,8 @@ import type { LayoutServerLoad } from './$types'; import { redirect } from '@sveltejs/kit'; import { loadFlash } from 'sveltekit-flash-message/server'; -import { setLanguageTag, sourceLanguageTag } from '$paraglide/runtime'; +import { setLanguageTag } from '$paraglide/runtime'; +import { DEFAULT_LANGUAGE } from '$lib/utils/constants'; const loginPageRegex = /^[a-zA-Z0-9]+:\/\/[^\/]+\/login\/?.*$/; @@ -21,6 +22,6 @@ export const load = loadFlash(async ({ locals, url, cookies, request }) => { }); } } - setLanguageTag(cookies.get('ciso_lang') || sourceLanguageTag); + setLanguageTag(cookies.get('ciso_lang') || DEFAULT_LANGUAGE); return { user: locals.user, settings: locals.settings }; }) satisfies LayoutServerLoad; diff --git a/frontend/src/routes/(authentication)/login/+page.server.ts b/frontend/src/routes/(authentication)/login/+page.server.ts index 7b118aa89..d8d371a5b 100644 --- a/frontend/src/routes/(authentication)/login/+page.server.ts +++ b/frontend/src/routes/(authentication)/login/+page.server.ts @@ -8,6 +8,7 @@ import { setError, superValidate } from 'sveltekit-superforms'; import { zod } from 'sveltekit-superforms/adapters'; import type { PageServerLoad } from './$types'; import { mfaAuthenticateSchema } from './mfa/utils/schemas'; +import { DEFAULT_LANGUAGE } from '$lib/utils/constants'; interface AuthenticationFlow { id: @@ -125,8 +126,8 @@ export const actions: Actions = { const preferencesRes = await fetch(`${BASE_API_URL}/user-preferences/`); const preferences = await preferencesRes.json(); - const currentLang = cookies.get('ciso_lang') || 'en'; - const preferedLang = preferences.lang || 'en'; + const currentLang = cookies.get('ciso_lang') || DEFAULT_LANGUAGE; + const preferedLang = preferences.lang || DEFAULT_LANGUAGE; if (currentLang !== preferedLang) { cookies.set('ciso_lang', preferedLang, { diff --git a/frontend/src/routes/(authentication)/password-reset/confirm/+page.server.ts b/frontend/src/routes/(authentication)/password-reset/confirm/+page.server.ts index 126a95820..34f993d27 100644 --- a/frontend/src/routes/(authentication)/password-reset/confirm/+page.server.ts +++ b/frontend/src/routes/(authentication)/password-reset/confirm/+page.server.ts @@ -7,8 +7,11 @@ import { setFlash } from 'sveltekit-flash-message/server'; import { setError, superValidate } from 'sveltekit-superforms'; import { zod } from 'sveltekit-superforms/adapters'; import type { PageServerLoad } from './$types'; +import { setLanguageTag } from '$paraglide/runtime'; +import { DEFAULT_LANGUAGE } from '$lib/utils/constants'; export const load: PageServerLoad = async (event) => { + setLanguageTag(event.cookies.get('ciso_lang') || DEFAULT_LANGUAGE); const form = await superValidate(event.request, zod(ResetPasswordSchema)); return { form }; diff --git a/frontend/src/routes/(authentication)/password-reset/confirm/+page.svelte b/frontend/src/routes/(authentication)/password-reset/confirm/+page.svelte index d09d5d82f..c49ece59c 100644 --- a/frontend/src/routes/(authentication)/password-reset/confirm/+page.svelte +++ b/frontend/src/routes/(authentication)/password-reset/confirm/+page.svelte @@ -5,6 +5,7 @@ import TextField from '$lib/components/Forms/TextField.svelte'; import { ResetPasswordSchema } from '$lib/utils/schemas'; import { zod } from 'sveltekit-superforms/adapters'; + import * as m from '$paraglide/messages.js'; export let data: PageData; @@ -21,7 +22,7 @@
- You can reset your password here.
+ {m.resetPasswordHere()}
{m.resetPassword()}
diff --git a/frontend/src/routes/+layout.server.ts b/frontend/src/routes/+layout.server.ts index 6cfa95884..e04d0fa2f 100644 --- a/frontend/src/routes/+layout.server.ts +++ b/frontend/src/routes/+layout.server.ts @@ -1,5 +1,9 @@ import type { LayoutServerLoad } from './$types'; +import { setLanguageTag } from '$paraglide/runtime'; +import { DEFAULT_LANGUAGE } from '$lib/utils/constants'; -export const load: LayoutServerLoad = async ({ locals }) => { +export const load: LayoutServerLoad = async ({ locals, cookies }) => { + setLanguageTag(cookies.get('ciso_lang') || DEFAULT_LANGUAGE); return { featureFlags: locals.featureFlags }; }; + diff --git a/frontend/src/routes/ParaglideJsProvider.svelte b/frontend/src/routes/ParaglideJsProvider.svelte index 777a8ae3a..02249a03b 100644 --- a/frontend/src/routes/ParaglideJsProvider.svelte +++ b/frontend/src/routes/ParaglideJsProvider.svelte @@ -3,15 +3,15 @@ languageTag, onSetLanguageTag, setLanguageTag, - sourceLanguageTag } from '$paraglide/runtime'; import { onDestroy, onMount } from 'svelte'; import { browser } from '$app/environment'; import { getCookie, deleteCookie, setCookie } from '$lib/utils/cookies'; + import { DEFAULT_LANGUAGE } from '$lib/utils/constants'; onMount(() => { - // const valueFromSession = sessionStorage.getItem('lang') || sourceLanguageTag; - const valueFromCookies = getCookie('ciso_lang') || sourceLanguageTag; + // const valueFromSession = sessionStorage.getItem('lang') || DEFAULT_LANGUAGE; + const valueFromCookies = getCookie('ciso_lang') || DEFAULT_LANGUAGE; // @ts-ignore setCookie('ciso_lang', valueFromCookies); setLanguageTag(valueFromCookies);