From 7d407db1efc1ddb97346142f073be4c9688eb144 Mon Sep 17 00:00:00 2001 From: Halit Aksoy Date: Tue, 18 Jun 2024 01:02:29 +0300 Subject: [PATCH] (frontend) fix current lang --- frontend/src/MancalaApp.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/frontend/src/MancalaApp.tsx b/frontend/src/MancalaApp.tsx index 1354c35..85b1831 100644 --- a/frontend/src/MancalaApp.tsx +++ b/frontend/src/MancalaApp.tsx @@ -24,7 +24,7 @@ const context = initContext(); const MancalaApp: FunctionComponent = () => { - const { t } = useTranslation(); + const { t, i18n } = useTranslation(); const [userKey, setUserKey] = useState(undefined); @@ -38,6 +38,12 @@ const MancalaApp: FunctionComponent = () => { const onThemeChange = (theme: Theme) => setTheme(theme); + React.useEffect(() => { + //@ts-ignore + const deviceLanguage = navigator.language || navigator.userLanguage; + i18n.changeLanguage(deviceLanguage === "tr-TR" ? "tr" : "en") + }, []); + const connectRTMT = (userKey: string) => { const rtmt = context.rtmt as RTMTWS; rtmt.on("error", onConnectionError);