mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-25 11:46:12 +01:00
🎙️ a11y: update html lang attribute (#3636)
* refactor: remove duplicate localStorage lang call * refactor: use cookies to handle langcode * feat: override index.html lang w/ cookie pref * refactor: only read index on server start * refactor: rename lang cookie & localstorage as backup * refactor: use atomWithLocalStorage in language store * fix: forced reflow warning in language select
This commit is contained in:
parent
a0042317b2
commit
2ce4f66218
7 changed files with 71 additions and 19 deletions
|
|
@ -1,10 +1,11 @@
|
|||
import { atom } from 'recoil';
|
||||
import Cookies from 'js-cookie';
|
||||
import { atomWithLocalStorage } from './utils';
|
||||
|
||||
const userLang = navigator.language || navigator.languages[0];
|
||||
const defaultLang = () => {
|
||||
const userLang = navigator.language || navigator.languages[0];
|
||||
return Cookies.get('lang') || localStorage.getItem('lang') || userLang;
|
||||
};
|
||||
|
||||
const lang = atom({
|
||||
key: 'lang',
|
||||
default: localStorage.getItem('lang') || userLang,
|
||||
});
|
||||
const lang = atomWithLocalStorage('lang', defaultLang());
|
||||
|
||||
export default { lang };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue