Skip to content

Commit

Permalink
fix: store added locales in the same place as last selected locale
Browse files Browse the repository at this point in the history
  • Loading branch information
Grammostola committed Oct 7, 2024
1 parent dd264a2 commit e9fd31b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/controls/localization.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ const Localization = function Localization(options = {}) {
return Object.hasOwn(locales, locId);
}
function getStoredLocales() {
return JSON.parse(sessionStorage.getItem('addedLocales') || '[]');
return JSON.parse(localStorage.getItem('origoAddedLocales') || '[]');
}

const storedLocales = getStoredLocales();

// if there are session-stored locales at (re)startup then add these locally
// if there are local-stored locales at (re)startup then add these locally
if (storedLocales.length > 0) {
storedLocales.forEach(locale => {
locales[locale.id] = locale;
Expand All @@ -43,12 +43,12 @@ const Localization = function Localization(options = {}) {
}
}

function setStoredLocales(sessionLocales) {
sessionStorage.setItem('addedLocales', JSON.stringify(sessionLocales));
function setStoredLocales(localLocales) {
localStorage.setItem('origoAddedLocales', JSON.stringify(localLocales));
}

/**
* Adds an array of locales to the locales object and stores them in sessionStorage.
* Adds an array of locales to the locales object and stores them in localStorage.
*
* @param {Array} locs - An array of locale objects to be added. Defaults to an empty array if not provided.
* If a locale id matches a current locale then the current locale will be overwritten.
Expand Down

0 comments on commit e9fd31b

Please sign in to comment.