Update locale files for English, Traditional Chinese, and Simplified Chinese to include page titles for I/O section; refactor IOPage to dynamically display the localized title based on device language state.

This commit is contained in:
yangy
2026-05-14 15:33:00 +08:00
parent db4d8e5090
commit b5c0606972
4 changed files with 14 additions and 1 deletions
+11 -1
View File
@@ -10,6 +10,10 @@ import { cn } from "@/lib/utils";
import BottomNav from "@/components/BottomNav";
import { ChevronLeft } from "lucide-react";
import { useLocation } from "wouter";
import { useMemo } from "react";
import localeZh from "@/locales/data-zh.json";
import localeZhHK from "@/locales/data-zh-HK.json";
import localeEn from "@/locales/data-en.json";
interface IOOption {
index: number;
@@ -101,6 +105,12 @@ export default function IOPage() {
const [, setLocation] = useLocation();
const { deviceState, setInput, setOutput } = useDevice();
const ioPageTitle = useMemo(() => {
const lang = deviceState?.language;
const pack = lang === 0 ? localeEn : lang === 1 ? localeZhHK : localeZh;
return pack.source?.pageTitle ?? pack.source?.label ?? "输入输出";
}, [deviceState?.language]);
const currentInput = deviceState?.input ?? 1;
const currentOutput = deviceState?.output ?? 2;
@@ -110,7 +120,7 @@ export default function IOPage() {
<button onClick={() => setLocation("/")} className="mr-4 text-white/60 active:text-white transition-colors">
<ChevronLeft size={24} />
</button>
<h1 className="flex-1 text-center text-[17px] font-semibold text-white"></h1>
<h1 className="flex-1 text-center text-[17px] font-semibold text-white">{ioPageTitle}</h1>
<div className="w-8" />
</div>