From 0e08f8f46a3d4d9f5fed51e06495a8f0af94a399 Mon Sep 17 00:00:00 2001 From: Jing Hua Date: Mon, 27 Mar 2023 11:39:21 +0800 Subject: [PATCH] i18n: html lang attribute --- src/App.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/App.tsx b/src/App.tsx index 4d6ad89..565dd5d 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,5 +1,6 @@ import React, { useEffect } from 'react'; import useStore from '@store/store'; +import i18n from './i18n'; import Chat from '@components/Chat'; import Menu from '@components/Menu'; @@ -16,6 +17,13 @@ function App() { const setApiKey = useStore((state) => state.setApiKey); const setCurrentChatIndex = useStore((state) => state.setCurrentChatIndex); + useEffect(() => { + document.documentElement.lang = i18n.language; + i18n.on('languageChanged', (lng) => { + document.documentElement.lang = lng; + }); + }, []); + useEffect(() => { // legacy local storage const oldChats = localStorage.getItem('chats');