Skip to content

Commit

Permalink
Add saving language to local storage
Browse files Browse the repository at this point in the history
  • Loading branch information
AnotherPillow committed Dec 27, 2023
1 parent f424beb commit 187c602
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ for (const key of Object.keys(supported_languages)) {
li.innerHTML = `<h1>${lang['flag']}</h1>`

li.addEventListener('click', () => {
localStorage.setItem('chosen-language', key)
loadTranslations(key)
})

Expand Down
2 changes: 1 addition & 1 deletion src/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ window.loadTranslations = async (_lang = lang) => {
})
}

loadTranslations()
loadTranslations(localStorage.getItem('chosen-language') ?? lang)

0 comments on commit 187c602

Please sign in to comment.