mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 08:59:57 +08:00
Adds `de` alongside en/zh/fr/uk, following the seams the Ukrainian locale established: the interface-language normalizers (settings + launcher), the Settings language list, APP_LANGUAGES / normalizeLanguage, the lazy bundle loader, the date locale, the CLI banner labels, the quiz-judge prompt and the i18n audit's required locales. German already existed as a reply language; this makes it selectable for the UI as well. `web/locales/de/app.json` covers all 5200 English keys (audit: 3850/3850 used keys, strict). `language.german` is added to every catalog. Tests: `tests/i18n/test_german_locale.py` pins each seam, and `web/tests/german-locale-quality.test.ts` guards terminology (informal "du", one term per concept, no context-free machine translations such as "Lappen" for RAG). Three existing tests used `de` as their example of an unsupported language; they now use `xx`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
32 lines
795 B
TypeScript
32 lines
795 B
TypeScript
import type { AppLanguage } from "@/i18n/languages";
|
|
|
|
export type Language = AppLanguage;
|
|
|
|
export function getLocale(lang: Language): string {
|
|
if (lang === "zh") return "zh-CN";
|
|
if (lang === "fr") return "fr-FR";
|
|
if (lang === "de") return "de-DE";
|
|
if (lang === "uk") return "uk-UA";
|
|
return "en-US";
|
|
}
|
|
|
|
export function formatDate(
|
|
date: Date,
|
|
lang: Language,
|
|
options: Intl.DateTimeFormatOptions = {
|
|
year: "numeric",
|
|
month: "short",
|
|
day: "numeric",
|
|
},
|
|
): string {
|
|
return new Intl.DateTimeFormat(getLocale(lang), options).format(date);
|
|
}
|
|
|
|
export function formatTime(
|
|
date: Date,
|
|
lang: Language,
|
|
options: Intl.DateTimeFormatOptions = { hour: "2-digit", minute: "2-digit" },
|
|
): string {
|
|
return new Intl.DateTimeFormat(getLocale(lang), options).format(date);
|
|
}
|