From 61b655e41d0a3cd9e7e1ae86a7afead587794f0f Mon Sep 17 00:00:00 2001 From: Stefan Peters Date: Tue, 28 May 2024 14:43:54 +0200 Subject: [PATCH] Update local storage key to include path --- src/client/config.js | 3 +++ src/client/i18n.js | 3 ++- src/client/store.js | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/client/config.js b/src/client/config.js index b73c971..b2d6ebd 100644 --- a/src/client/config.js +++ b/src/client/config.js @@ -1,6 +1,9 @@ // eslint-disable-next-line no-undef const config = __CONFIG__ config.namespace = new URL(config.namespace) +config.localStorageKeys = { + locale: `jskos-proxy${config.namespace.pathname.replaceAll("/", "-")}locale`, +} document.title = config.title diff --git a/src/client/i18n.js b/src/client/i18n.js index 39b3ed0..1b7df96 100644 --- a/src/client/i18n.js +++ b/src/client/i18n.js @@ -1,11 +1,12 @@ import { createI18n } from "vue-i18n" import messages from "#/locale.json" +import config from "@/config.js" let locale // Try to ready locale from local storage try { - locale = localStorage.getItem("locale") + locale = localStorage.getItem(config.localStorageKeys.locale) } catch (error) { console.warn("Error reading locale from local storage.") } diff --git a/src/client/store.js b/src/client/store.js index 98c8764..b79132a 100644 --- a/src/client/store.js +++ b/src/client/store.js @@ -31,7 +31,7 @@ export function setLocale(value) { // Adjust state.languages inline so that jskos-tools "reacts" state.languages.splice(0, 0, state.languages.splice(index, 1)[0]) try { - localStorage.setItem("locale", value) + localStorage.setItem(config.localStorageKeys.locale, value) } catch (error) { console.error("Error storing locale in local storage", error) }