From ed44add08d87fe66b47ebaa0b6cfeb335732bf18 Mon Sep 17 00:00:00 2001 From: Johnson Mao Date: Sat, 2 Nov 2024 21:18:00 +0800 Subject: [PATCH] chore: i18n --- features/room/components/CreateRoomForm/CreateRoomForm.tsx | 4 +++- public/locales/zh_TW/rooms.json | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/features/room/components/CreateRoomForm/CreateRoomForm.tsx b/features/room/components/CreateRoomForm/CreateRoomForm.tsx index 1275c8ea..3d5cff1c 100644 --- a/features/room/components/CreateRoomForm/CreateRoomForm.tsx +++ b/features/room/components/CreateRoomForm/CreateRoomForm.tsx @@ -1,5 +1,6 @@ import { useState, FormEvent, useRef, useEffect } from "react"; import { useRouter } from "next/router"; +import { useTranslation } from "react-i18next"; import useRequest from "@/hooks/useRequest"; import Button from "@/components/shared/Button/v2"; import Input from "@/components/shared/Input"; @@ -55,6 +56,7 @@ function CreateRoomForm({ }); const { fetch } = useRequest(); const router = useRouter(); + const { t } = useTranslation("rooms"); const [isLockRoom, setIsLockRoom] = useState(false); const passwordInputRef = useRef(null); const gameNameInputRef = useRef(null); @@ -77,7 +79,7 @@ function CreateRoomForm({ if (isLockRoom && roomForm.password?.length !== 4) { passwordInputRef.current?.focus(); - newErrors.password = "請輸入遊戲密碼"; + newErrors.password = t("enter_game_password"); } if (!roomForm.name) { gameNameInputRef.current?.focus(); diff --git a/public/locales/zh_TW/rooms.json b/public/locales/zh_TW/rooms.json index f388c10b..87a64d39 100644 --- a/public/locales/zh_TW/rooms.json +++ b/public/locales/zh_TW/rooms.json @@ -4,5 +4,6 @@ "you_can_only_join_1_room": "一人只能進入一間房!", "rooms_list": "查看房間列表", "rooms_waiting": "正在等待玩家配對", - "rooms_playing": "遊戲已開始" + "rooms_playing": "遊戲已開始", + "enter_game_password": "請輸入遊戲密碼" }