mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-05 06:09:40 +08:00
Add a complete Japanese web catalog (web/locales/ja/app.json, every key of the English catalog) and register "ja" wherever the other interface languages are listed: the web language registry and loader, date formatting, the backend UI-language setting and launch settings, and the generated API contracts. Each existing catalog gains language.japanese. Japanese was already a reply language; this makes it an interface language too, following the Polish integration. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
34 lines
869 B
TypeScript
34 lines
869 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";
|
|
if (lang === "pl") return "pl-PL";
|
|
if (lang === "ja") return "ja-JP";
|
|
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);
|
|
}
|