feat: align frontend languages with posts api
This commit is contained in:
@@ -8,9 +8,16 @@ export type DayGroup = {
|
||||
};
|
||||
|
||||
function localeFor(lang: string): string {
|
||||
if (lang === "zh-TW") return "zh-TW";
|
||||
if (lang === "zh-CN") return "zh-CN";
|
||||
return "en-US";
|
||||
const locales: Record<string, string> = {
|
||||
zh: "zh-CN",
|
||||
en: "en-US",
|
||||
ja: "ja-JP",
|
||||
ko: "ko-KR",
|
||||
vi: "vi-VN",
|
||||
id: "id-ID",
|
||||
ms: "ms-MY",
|
||||
};
|
||||
return locales[lang] ?? "en-US";
|
||||
}
|
||||
|
||||
function dayKey(iso: string): string {
|
||||
@@ -28,12 +35,10 @@ function dayLabel(iso: string, lang: string): string {
|
||||
a.getMonth() === b.getMonth() &&
|
||||
a.getDate() === b.getDate();
|
||||
if (isSameDay(d, today)) {
|
||||
if (lang === "en") return "Today";
|
||||
return "今天";
|
||||
return lang === "zh" ? "今天" : "Today";
|
||||
}
|
||||
if (isSameDay(d, yesterday)) {
|
||||
if (lang === "en") return "Yesterday";
|
||||
return "昨天";
|
||||
return lang === "zh" ? "昨天" : "Yesterday";
|
||||
}
|
||||
return new Intl.DateTimeFormat(localeFor(lang), {
|
||||
month: "long",
|
||||
|
||||
Reference in New Issue
Block a user