Skip to content

Commit

Permalink
refactor: rename lang cookie & localstorage as backup
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobcolyvan committed Aug 19, 2024
1 parent 01560c7 commit 6f5bc7a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion client/src/components/Nav/SettingsTabs/General/General.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ function General() {
}

setLangcode(userLang);
Cookies.set('langcode', userLang, { expires: 365 });
Cookies.set('lang', userLang, { expires: 365 });
localStorage.setItem('lang', userLang);
document.documentElement.lang = userLang;
},
[setLangcode],
Expand Down
2 changes: 1 addition & 1 deletion client/src/store/language.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const userLang = navigator.language || navigator.languages[0];

const lang = atom({
key: 'lang',
default: Cookies.get('langcode') || userLang,
default: Cookies.get('lang') || localStorage.getItem('lang') || userLang,
});

export default { lang };

0 comments on commit 6f5bc7a

Please sign in to comment.