feat(i18n): add Japanese language support

- Add complete Japanese translation file (ja.json)
- Update frontend types and hooks to support "ja" language option
- Add Japanese tray menu texts in Rust backend
- Add Japanese option to language settings component
- Update Zod schema to include Japanese language validation
- Add test case for Japanese language preference
- Update i18n documentation to reflect three-language support
This commit is contained in:
Jason
2025-11-28 15:14:39 +08:00
parent 1ee1e9cb2e
commit 00f78e4546
13 changed files with 900 additions and 16 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ import {
} from "./useDirectorySettings";
import { useSettingsMetadata } from "./useSettingsMetadata";
type Language = "zh" | "en";
type Language = "zh" | "en" | "ja";
interface SaveResult {
requiresRestart: boolean;
+5 -4
View File
@@ -3,7 +3,7 @@ import { useTranslation } from "react-i18next";
import { useSettingsQuery } from "@/lib/query";
import type { Settings } from "@/types";
type Language = "zh" | "en";
type Language = "zh" | "en" | "ja";
export type SettingsFormState = Omit<Settings, "language"> & {
language: Language;
@@ -11,7 +11,8 @@ export type SettingsFormState = Omit<Settings, "language"> & {
const normalizeLanguage = (lang?: string | null): Language => {
if (!lang) return "zh";
return lang === "en" ? "en" : "zh";
const normalized = lang.toLowerCase();
return normalized === "en" || normalized === "ja" ? normalized : "zh";
};
const sanitizeDir = (value?: string | null): string | undefined => {
@@ -51,8 +52,8 @@ export function useSettingsForm(): UseSettingsFormResult {
const readPersistedLanguage = useCallback((): Language => {
if (typeof window !== "undefined") {
const stored = window.localStorage.getItem("language");
if (stored === "en" || stored === "zh") {
return stored;
if (stored === "en" || stored === "zh" || stored === "ja") {
return stored as Language;
}
}
return normalizeLanguage(i18n.language);