diff --git a/src/i18n/index.ts b/src/i18n/index.ts index 6f3499f4d643831cd55c1932b38ecf74d95064d5..fbe8e3441a1ee3c135d9270ffdf890c5fb40b8c7 100644 --- a/src/i18n/index.ts +++ b/src/i18n/index.ts @@ -2,7 +2,10 @@ import Polyglot from 'node-polyglot' import { App, computed, reactive } from 'vue' import { has } from '@/utilities' -const DEFAULT_LOCALE = import.meta.env.VUE_APP_DEFAULT_LOCALE ?? 'de' +const STORAGE_KEY = 'aura:locale' + +const DEFAULT_LOCALE = + localStorage.getItem(STORAGE_KEY) ?? import.meta.env.VUE_APP_DEFAULT_LOCALE ?? 'de' const locales = Object.fromEntries( Object.entries(import.meta.glob('./??.js', { import: 'default', eager: true })).map( @@ -44,6 +47,7 @@ function updateLocale(newLocale: string): void { if (has(locales, newLocale)) { state.locale = newLocale state.polyglot = createPolyglot(newLocale) + localStorage.setItem(STORAGE_KEY, newLocale) } else { throw new Error(`Unknown locale code for language: ${newLocale}`) }