diff --git a/dictation_client/src/pages/SignupCompletePage/index.tsx b/dictation_client/src/pages/SignupCompletePage/index.tsx index 50822c5..9fd2c19 100644 --- a/dictation_client/src/pages/SignupCompletePage/index.tsx +++ b/dictation_client/src/pages/SignupCompletePage/index.tsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useEffect } from "react"; import { useTranslation } from "react-i18next"; import { getTranslationID } from "translation"; import Header from "components/header"; @@ -7,7 +7,18 @@ import styles from "styles/app.module.scss"; import emailCheck from "../../assets/images/email_check.svg"; const SignupCompletePage: React.FC = (): JSX.Element => { - const [t] = useTranslation(); + const [t, i18n] = useTranslation(); + + useEffect(() => { + const language = document.cookie + .split(";") + .map((x) => x.split("=")) + .find((x) => x.length === 2 && x[0] === "language"); + + if (language) { + i18n.changeLanguage(language[1]); + } + }, [i18n]); return (
diff --git a/dictation_client/src/pages/SignupPage/index.tsx b/dictation_client/src/pages/SignupPage/index.tsx index 4757cd3..e3a866b 100644 --- a/dictation_client/src/pages/SignupPage/index.tsx +++ b/dictation_client/src/pages/SignupPage/index.tsx @@ -1,15 +1,29 @@ import Footer from "components/footer"; import Header from "components/header"; import { selectPageState } from "features/signup/selectors"; -import React from "react"; +import React, { useEffect } from "react"; import { useSelector } from "react-redux"; import { Navigate } from "react-router-dom"; +import { useTranslation } from "react-i18next"; import SignupInput from "./signupInput"; import SignupConfirm from "./signupConfirm"; const SignupPage: React.FC<{ completeTo: string }> = ({ completeTo, }): JSX.Element => { + const { i18n } = useTranslation(); + + useEffect(() => { + const language = document.cookie + .split(";") + .map((x) => x.split("=")) + .find((x) => x.length === 2 && x[0] === "language"); + + if (language) { + i18n.changeLanguage(language[1]); + } + }, [i18n]); + const state = useSelector(selectPageState); return ( diff --git a/dictation_client/src/pages/VerifyAlreadyExistPage/index.tsx b/dictation_client/src/pages/VerifyAlreadyExistPage/index.tsx index 6da7d1c..08d7cf0 100644 --- a/dictation_client/src/pages/VerifyAlreadyExistPage/index.tsx +++ b/dictation_client/src/pages/VerifyAlreadyExistPage/index.tsx @@ -3,10 +3,22 @@ import Header from "components/header"; import styles from "styles/app.module.scss"; import { useTranslation } from "react-i18next"; import { getTranslationID } from "translation"; +import { useEffect } from "react"; import check_circle from "../../assets/images/check_circle.svg"; const VerifyPage: React.FC = (): JSX.Element => { - const [t] = useTranslation(); + const [t, i18n] = useTranslation(); + + useEffect(() => { + const language = document.cookie + .split(";") + .map((x) => x.split("=")) + .find((x) => x.length === 2 && x[0] === "language"); + + if (language) { + i18n.changeLanguage(language[1]); + } + }, [i18n]); return (
diff --git a/dictation_client/src/pages/VerifyFailedPage/index.tsx b/dictation_client/src/pages/VerifyFailedPage/index.tsx index ddbc089..4d0666d 100644 --- a/dictation_client/src/pages/VerifyFailedPage/index.tsx +++ b/dictation_client/src/pages/VerifyFailedPage/index.tsx @@ -7,11 +7,18 @@ import { getTranslationID } from "translation"; import report from "../../assets/images/report.svg"; const VerifyFailedPage: React.FC = (): JSX.Element => { - const [t] = useTranslation(); + const [t, i18n] = useTranslation(); useEffect(() => { - // 初期表示時の処理を記述 - }, []); + const language = document.cookie + .split(";") + .map((x) => x.split("=")) + .find((x) => x.length === 2 && x[0] === "language"); + + if (language) { + i18n.changeLanguage(language[1]); + } + }, [i18n]); return (
diff --git a/dictation_client/src/pages/VerifySuccessPage/index.tsx b/dictation_client/src/pages/VerifySuccessPage/index.tsx index 2761ee7..0340934 100644 --- a/dictation_client/src/pages/VerifySuccessPage/index.tsx +++ b/dictation_client/src/pages/VerifySuccessPage/index.tsx @@ -3,10 +3,22 @@ import Header from "components/header"; import styles from "styles/app.module.scss"; import { useTranslation } from "react-i18next"; import { getTranslationID } from "translation"; +import { useEffect } from "react"; import check_circle from "../../assets/images/check_circle.svg"; const VerifySuccessPage: React.FC = (): JSX.Element => { - const [t] = useTranslation(); + const [t, i18n] = useTranslation(); + + useEffect(() => { + const language = document.cookie + .split(";") + .map((x) => x.split("=")) + .find((x) => x.length === 2 && x[0] === "language"); + + if (language) { + i18n.changeLanguage(language[1]); + } + }, [i18n]); return (