refactor: unify i18n function calls and simplify scripts

- Replace dynamic t(lang.labelKey) with static t(lang.label) using helper functions
- Add getLanguageLabel/getLangLabel/getLocaleLabel helper functions for switch-based label lookup
- Simplify translation check scripts to only detect literal string calls
- Fix namespace lookup for dotted namespaces like 'memorize.review'
This commit is contained in:
2026-03-18 08:13:58 +08:00
parent 286add7fff
commit 1ef337801d
6 changed files with 239 additions and 342 deletions

View File

@@ -13,11 +13,18 @@ import { actionCreateCard } from "@/modules/card/card-action";
import type { CardType, CardMeaning } from "@/modules/card/card-action-dto";
import { toast } from "sonner";
const QUERY_LANGUAGE_LABELS = {
english: "english",
chinese: "chinese",
japanese: "japanese",
korean: "korean",
} as const;
const QUERY_LANGUAGES = [
{ value: "en", labelKey: "english" },
{ value: "zh", labelKey: "chinese" },
{ value: "ja", labelKey: "japanese" },
{ value: "ko", labelKey: "korean" },
{ value: "en", label: "english" as const },
{ value: "zh", label: "chinese" as const },
{ value: "ja", label: "japanese" as const },
{ value: "ko", label: "korean" as const },
] as const;
interface AddCardModalProps {
@@ -169,7 +176,7 @@ export function AddCardModal({
}}
size="sm"
>
{t(lang.labelKey)}
{t(lang.label)}
</LightButton>
))}
<Input