From 5a767dae343faffcbf715e64c087c7eedfb5a0b8 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 24 Aug 2025 11:05:52 +0300 Subject: [PATCH] feat(i18n): add support for Brazilian Portuguese --- .../src/widgets/view_widgets/calendar_view.ts | 2 + apps/server/src/services/i18n.ts | 7 ++- packages/commons/src/lib/i18n.ts | 61 ++++--------------- 3 files changed, 18 insertions(+), 52 deletions(-) diff --git a/apps/client/src/widgets/view_widgets/calendar_view.ts b/apps/client/src/widgets/view_widgets/calendar_view.ts index d49caa528..febac6f4d 100644 --- a/apps/client/src/widgets/view_widgets/calendar_view.ts +++ b/apps/client/src/widgets/view_widgets/calendar_view.ts @@ -676,6 +676,8 @@ export async function getFullCalendarLocale(locale: string) { return (await import("@fullcalendar/core/locales/ru")).default; case "ja": return (await import("@fullcalendar/core/locales/ja")).default; + case "pt_BR": + return (await import("@fullcalendar/core/locales/pt-br")).default; case "uk": return (await import("@fullcalendar/core/locales/uk")).default; case "en": diff --git a/apps/server/src/services/i18n.ts b/apps/server/src/services/i18n.ts index beb443a19..c849ecc5a 100644 --- a/apps/server/src/services/i18n.ts +++ b/apps/server/src/services/i18n.ts @@ -18,6 +18,7 @@ const DAYJS_LOADER: Record Promise import("dayjs/locale/he.js"), "ja": () => import("dayjs/locale/ja.js"), "ku": () => import("dayjs/locale/ku.js"), + "pt_BR": () => import("dayjs/locale/pt_BR.js"), "ro": () => import("dayjs/locale/ro.js"), "ru": () => import("dayjs/locale/ru.js"), "tw": () => import("dayjs/locale/zh-tw.js"), @@ -40,8 +41,10 @@ export async function initializeTranslations() { }); // Initialize dayjs locale. - const dayjsLocale = await DAYJS_LOADER[locale](); - dayjs.locale(dayjsLocale); + const dayjsLocale = DAYJS_LOADER[locale]; + if (dayjsLocale) { + dayjs.locale(await dayjsLocale()); + } } export function ordinal(date: Dayjs) { diff --git a/packages/commons/src/lib/i18n.ts b/packages/commons/src/lib/i18n.ts index ad0462c79..24d775658 100644 --- a/packages/commons/src/lib/i18n.ts +++ b/packages/commons/src/lib/i18n.ts @@ -10,56 +10,17 @@ export interface Locale { } const UNSORTED_LOCALES: Locale[] = [ - { - id: "en", - name: "English", - electronLocale: "en" - }, - { - id: "de", - name: "Deutsch", - electronLocale: "de" - }, - { - id: "es", - name: "Español", - electronLocale: "es" - }, - { - id: "fr", - name: "Français", - electronLocale: "fr" - }, - { - id: "cn", - name: "简体中文", - electronLocale: "zh_CN" - }, - { - id: "tw", - name: "繁體中文", - electronLocale: "zh_TW" - }, - { - id: "ro", - name: "Română", - electronLocale: "ro" - }, - { - id: "ru", - name: "Русский", - electronLocale: "ru" - }, - { - id: "uk", - name: "Українська", - electronLocale: "uk" - }, - { - id: "ja", - name: "日本語", - electronLocale: "ja" - }, + { id: "cn", name: "简体中文", electronLocale: "zh_CN" }, + { id: "de", name: "Deutsch", electronLocale: "de" }, + { id: "en", name: "English", electronLocale: "en" }, + { id: "es", name: "Español", electronLocale: "es" }, + { id: "fr", name: "Français", electronLocale: "fr" }, + { id: "ja", name: "日本語", electronLocale: "ja" }, + { id: "pt_BR", name: "Português (Brasil)", electronLocale: "pt-BR" }, + { id: "ro", name: "Română", electronLocale: "ro" }, + { id: "ru", name: "Русский", electronLocale: "ru" }, + { id: "tw", name: "繁體中文", electronLocale: "zh_TW" }, + { id: "uk", name: "Українська", electronLocale: "uk" }, /* * Right to left languages