Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

🌐 Streamline supported languages (#1728)

Luke Vella061989d241d5
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<ILocale>;
}
> = {
- 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 (
<DayjsProvider
config={{
- locale: i18n.language,
+ locale: i18n.language as SupportedLocale,
timeZone: preferences.timeZone ?? undefined,
localeOverrides: {
weekStart: preferences.weekStart ?? undefined,
diff --git a/packages/languages/src/index.ts b/packages/languages/src/index.ts
index 0260c39f3..b6e1484b3 100644
--- a/packages/languages/src/index.ts
+++ b/packages/languages/src/index.ts
@@ -1,4 +1,6 @@
-import languages from "./languages.json";
+import { languages } from "./languages";
+
+export type SupportedLocale = keyof typeof languages;
export const supportedLngs = Object.keys(languages);
diff --git a/packages/languages/src/languages.json b/packages/languages/src/languages.json
deleted file mode 100644
index 83674960e..000000000
--- a/packages/languages/src/languages.json
+++ /dev/null
@@ -1,25 +0,0 @@
-{
- "eu": "Basque",
- "ca": "Català",
- "cs": "Česky",
- "da": "Dansk",
- "de": "Deutsch",
- "en": "English",
- "en-GB": "English (UK)",
- "es": "Español",
- "fr": "Français",
- "hr": "Hrvatski",
- "it": "Italiano",
- "hu": "Magyar",
- "nl": "Nederlands",
- "no": "Norsk",
- "pl": "Polski",
- "pt-BR": "Português - Brasil",
- "ru": "Русский",
- "sk": "Slovenčina",
- "fi": "Suomi",
- "sv": "Svenska",
- "tr": "Türkçe",
- "zh": "简体中文",
- "zh-Hant": "繁體中文"
-}
diff --git a/packages/languages/src/languages.ts b/packages/languages/src/languages.ts
new file mode 100644
index 000000000..b3730e3b9
--- /dev/null
+++ b/packages/languages/src/languages.ts
@@ -0,0 +1,20 @@
+export const languages = {
+ cs: "Česky",
+ da: "Dansk",
+ de: "Deutsch",
+ en: "English",
+ "en-GB": "English (UK)",
+ es: "Español",
+ fr: "Français",
+ it: "Italiano",
+ hu: "Magyar",
+ nl: "Nederlands",
+ no: "Norsk",
+ pl: "Polski",
+ pt: "Português",
+ "pt-BR": "Português - Brasil",
+ ru: "Русский",
+ fi: "Suomi",
+ sv: "Svenska",
+ zh: "简体中文",
+};