i18n: html lang attribute

This commit is contained in:
Jing Hua 2023-03-27 11:39:21 +08:00
parent c06415d4fb
commit 0e08f8f46a

View file

@ -1,5 +1,6 @@
import React, { useEffect } from 'react'; import React, { useEffect } from 'react';
import useStore from '@store/store'; import useStore from '@store/store';
import i18n from './i18n';
import Chat from '@components/Chat'; import Chat from '@components/Chat';
import Menu from '@components/Menu'; import Menu from '@components/Menu';
@ -16,6 +17,13 @@ function App() {
const setApiKey = useStore((state) => state.setApiKey); const setApiKey = useStore((state) => state.setApiKey);
const setCurrentChatIndex = useStore((state) => state.setCurrentChatIndex); const setCurrentChatIndex = useStore((state) => state.setCurrentChatIndex);
useEffect(() => {
document.documentElement.lang = i18n.language;
i18n.on('languageChanged', (lng) => {
document.documentElement.lang = lng;
});
}, []);
useEffect(() => { useEffect(() => {
// legacy local storage // legacy local storage
const oldChats = localStorage.getItem('chats'); const oldChats = localStorage.getItem('chats');