Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(i18n): pt_BR still not working
Elian Doran83d1a68879f3
diff --git a/apps/client/src/widgets/view_widgets/calendar_view.ts b/apps/client/src/widgets/view_widgets/calendar_view.tsindex 8da330ed81..ff32474f1b 100644--- a/apps/client/src/widgets/view_widgets/calendar_view.ts+++ b/apps/client/src/widgets/view_widgets/calendar_view.ts@@ -1,4 +1,4 @@-import type { Calendar, DateSelectArg, DatesSetArg, EventChangeArg, EventDropArg, EventInput, EventSourceFunc, EventSourceFuncArg, EventSourceInput, PluginDef } from "@fullcalendar/core";+import type { Calendar, DateSelectArg, DatesSetArg, EventChangeArg, EventDropArg, EventInput, EventSourceFunc, EventSourceFuncArg, EventSourceInput, LocaleInput, PluginDef } from "@fullcalendar/core";import froca from "../../services/froca.js";import ViewMode, { type ViewModeArgs } from "./view_mode.js";import type FNote from "../../entities/fnote.js";@@ -15,6 +15,22 @@ import type { EventImpl } from "@fullcalendar/core/internal";import debounce, { type DebouncedFunction } from "debounce";import type { TouchBarItem } from "../../components/touch_bar.js";import type { SegmentedControlSegment } from "electron";+import { LOCALE_IDS } from "@triliumnext/commons";++// Here we hard-code the imports in order to ensure that they are embedded by webpack without having to load all the languages.+const LOCALE_MAPPINGS: Record<LOCALE_IDS, (() => Promise<{ default: LocaleInput }>) | null> = {+ de: () => import("@fullcalendar/core/locales/de"),+ es: () => import("@fullcalendar/core/locales/es"),+ fr: () => import("@fullcalendar/core/locales/fr"),+ cn: () => import("@fullcalendar/core/locales/zh-cn"),+ tw: () => import("@fullcalendar/core/locales/zh-tw"),+ ro: () => import("@fullcalendar/core/locales/ro"),+ ru: () => import("@fullcalendar/core/locales/ru"),+ ja: () => import("@fullcalendar/core/locales/ja"),+ "pt_br": () => import("@fullcalendar/core/locales/pt-br"),+ uk: () => import("@fullcalendar/core/locales/uk"),+ en: null+};const TPL = /*html*/`<div class="calendar-view">@@ -657,31 +673,11 @@ export default class CalendarView extends ViewMode<{}> {}-export async function getFullCalendarLocale(locale: string) {- // Here we hard-code the imports in order to ensure that they are embedded by webpack without having to load all the languages.- switch (locale) {- case "de":- return (await import("@fullcalendar/core/locales/de")).default;- case "es":- return (await import("@fullcalendar/core/locales/es")).default;- case "fr":- return (await import("@fullcalendar/core/locales/fr")).default;- case "cn":- return (await import("@fullcalendar/core/locales/zh-cn")).default;- case "tw":- return (await import("@fullcalendar/core/locales/zh-tw")).default;- case "ro":- return (await import("@fullcalendar/core/locales/ro")).default;- case "ru":- 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":- default:- return undefined;+export async function getFullCalendarLocale(locale: LOCALE_IDS) {+ const correspondingLocale = LOCALE_MAPPINGS[locale];+ if (correspondingLocale) {+ return (await correspondingLocale()).default;+ } else {+ return undefined;}}diff --git a/packages/commons/src/lib/i18n.ts b/packages/commons/src/lib/i18n.tsindex ff435de785..d40f5ecc5d 100644--- a/packages/commons/src/lib/i18n.ts+++ b/packages/commons/src/lib/i18n.ts@@ -16,7 +16,7 @@ const UNSORTED_LOCALES: Locale[] = [{ 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: "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" },