Skip to content

Commit

Permalink
Fix language selection logic in Si18n class
Browse files Browse the repository at this point in the history
  • Loading branch information
jdbruxelles committed Jan 11, 2024
1 parent d16479a commit 30c8240
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/si18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,15 @@ export default class Si18n {

const searchParam = new URLSearchParams(window.location.search);
const langInURL = searchParam.get(this.#options.saveAs);
const savedLag = localStorage.getItem(this.#options.saveAs);

if (!Si18n.#isUndefined(_options.saveLang)) {
this.#options.saveLang = _options.saveLang;
}

if (langInURL !== null && this.#options.availableLocales.includes(langInURL)) {
this.#options.lang = langInURL;
} else if (this.#options.saveLang) {
} else if (this.#options.saveLang && savedLag) {
this.#options.lang = localStorage.getItem(this.#options.saveAs) || _options.lang;
} else if (_options.lang) {
this.#options.lang = _options.lang;
Expand Down

0 comments on commit 30c8240

Please sign in to comment.