Skip to content

Commit

Permalink
Update local storage key to include path
Browse files Browse the repository at this point in the history
  • Loading branch information
stefandesu committed May 28, 2024
1 parent 24ae6fd commit 61b655e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/client/config.js
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 2 additions & 1 deletion src/client/i18n.js
Original file line number Diff line number Diff line change
@@ -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.")
}
Expand Down
2 changes: 1 addition & 1 deletion src/client/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 61b655e

Please sign in to comment.