From 061989d241d540640d061ae3a0cdf8966f6fcede Mon Sep 17 00:00:00 2001 From: Luke Vella Date: Sun, 25 May 2025 11:33:24 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=90=20Streamline=20supported=20languag?= =?UTF-8?q?es=20(#1728)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web/src/utils/dayjs.tsx | 42 +++------------------------ packages/languages/src/index.ts | 4 ++- packages/languages/src/languages.json | 25 ---------------- packages/languages/src/languages.ts | 20 +++++++++++++ 4 files changed, 27 insertions(+), 64 deletions(-) delete mode 100644 packages/languages/src/languages.json create mode 100644 packages/languages/src/languages.ts diff --git a/apps/web/src/utils/dayjs.tsx b/apps/web/src/utils/dayjs.tsx index cffab6663..7a447cbd4 100644 --- a/apps/web/src/utils/dayjs.tsx +++ b/apps/web/src/utils/dayjs.tsx @@ -21,21 +21,17 @@ import { usePreferences } from "@/contexts/preferences"; import { useTranslation } from "@/i18n/client"; import { getBrowserTimeZone, normalizeTimeZone } from "@/utils/date-time-utils"; +import type { SupportedLocale } from "@rallly/languages"; import { useRequiredContext } from "../components/use-required-context"; const dayjsLocales: Record< - string, + SupportedLocale, { weekStart: number; timeFormat: TimeFormat; import: () => Promise; } > = { - eu: { - weekStart: 1, - timeFormat: "hours24", - import: () => import("dayjs/locale/eu"), - }, en: { weekStart: 1, timeFormat: "hours12", @@ -51,11 +47,6 @@ const dayjsLocales: Record< timeFormat: "hours24", import: () => import("dayjs/locale/es"), }, - ca: { - weekStart: 1, - timeFormat: "hours24", - import: () => import("dayjs/locale/ca"), - }, da: { weekStart: 1, timeFormat: "hours24", @@ -76,11 +67,6 @@ const dayjsLocales: Record< timeFormat: "hours24", import: () => import("dayjs/locale/fr"), }, - hr: { - weekStart: 1, - timeFormat: "hours24", - import: () => import("dayjs/locale/hr"), - }, it: { weekStart: 1, timeFormat: "hours24", @@ -91,11 +77,6 @@ const dayjsLocales: Record< timeFormat: "hours24", import: () => import("dayjs/locale/sv"), }, - sk: { - weekStart: 1, - timeFormat: "hours24", - import: () => import("dayjs/locale/sk"), - }, cs: { weekStart: 1, timeFormat: "hours24", @@ -141,21 +122,6 @@ const dayjsLocales: Record< timeFormat: "hours24", import: () => import("dayjs/locale/zh"), }, - "zh-Hant": { - weekStart: 0, - timeFormat: "hours24", - import: () => import("dayjs/locale/zh-tw"), - }, - vi: { - weekStart: 1, - timeFormat: "hours24", - import: () => import("dayjs/locale/vi"), - }, - tr: { - weekStart: 1, - timeFormat: "hours24", - import: () => import("dayjs/locale/tr"), - }, }; dayjs.extend(localizedFormat); @@ -195,7 +161,7 @@ export const useDayjs = () => { export const DayjsProvider: React.FunctionComponent<{ children?: React.ReactNode; config?: { - locale?: string; + locale?: SupportedLocale; timeZone?: string; localeOverrides?: { weekStart?: number; @@ -281,7 +247,7 @@ export const ConnectedDayjsProvider = ({ return (