From f75b8545b1cd41ba8bca3a9b3170e7237a7e1a88 Mon Sep 17 00:00:00 2001 From: "makabe.t" Date: Tue, 11 Apr 2023 10:50:15 +0000 Subject: [PATCH] =?UTF-8?q?Merged=20PR=2074:=20develop=E5=8B=95=E4=BD=9C?= =?UTF-8?q?=E7=A2=BA=E8=AA=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 概要 [Task1498: develop動作確認](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/1498) - 言語の読み取りと描画のタイミングで言語切り替えが凡例されないことがあるので、各ページで実施するように修正しました。 ## レビューポイント - 共有 - 後ほどしっかりしたロジックを検討します。 ## UIの変更 ## 動作確認状況 - ローカルで確認 --- .../src/pages/SignupCompletePage/index.tsx | 15 +++++++++++++-- dictation_client/src/pages/SignupPage/index.tsx | 16 +++++++++++++++- .../src/pages/VerifyAlreadyExistPage/index.tsx | 14 +++++++++++++- .../src/pages/VerifyFailedPage/index.tsx | 13 ++++++++++--- .../src/pages/VerifySuccessPage/index.tsx | 14 +++++++++++++- 5 files changed, 64 insertions(+), 8 deletions(-) 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 (