mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 06:09:33 +08:00
Combine Hungarian with Italian UI and Hindi reply-language registries; translate 49 newly integrated keys and add the Hungarian endonym to Italian. Regenerate router and frontend contracts. 33 Python locale tests, full Node suite and locale parity pass.
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
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 === "pt") return "pt-BR";
|
|
if (lang === "vi") return "vi-VN";
|
|
if (lang === "ja") return "ja-JP";
|
|
if (lang === "tr") return "tr-TR";
|
|
if (lang === "ko") return "ko-KR";
|
|
if (lang === "it") return "it-IT";
|
|
if (lang === "hu") return "hu-HU";
|
|
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);
|
|
}
|