1- import type { Calendar , DateSelectArg , DatesSetArg , EventChangeArg , EventDropArg , EventInput , EventSourceFunc , EventSourceFuncArg , EventSourceInput , PluginDef } from "@fullcalendar/core" ;
1+ import type { Calendar , DateSelectArg , DatesSetArg , EventChangeArg , EventDropArg , EventInput , EventSourceFunc , EventSourceFuncArg , EventSourceInput , LocaleInput , PluginDef } from "@fullcalendar/core" ;
22import froca from "../../services/froca.js" ;
33import ViewMode , { type ViewModeArgs } from "./view_mode.js" ;
44import type FNote from "../../entities/fnote.js" ;
@@ -15,6 +15,22 @@ import type { EventImpl } from "@fullcalendar/core/internal";
1515import debounce , { type DebouncedFunction } from "debounce" ;
1616import type { TouchBarItem } from "../../components/touch_bar.js" ;
1717import type { SegmentedControlSegment } from "electron" ;
18+ import { LOCALE_IDS } from "@triliumnext/commons" ;
19+
20+ // Here we hard-code the imports in order to ensure that they are embedded by webpack without having to load all the languages.
21+ const LOCALE_MAPPINGS : Record < LOCALE_IDS , ( ( ) => Promise < { default : LocaleInput } > ) | null > = {
22+ de : ( ) => import ( "@fullcalendar/core/locales/de" ) ,
23+ es : ( ) => import ( "@fullcalendar/core/locales/es" ) ,
24+ fr : ( ) => import ( "@fullcalendar/core/locales/fr" ) ,
25+ cn : ( ) => import ( "@fullcalendar/core/locales/zh-cn" ) ,
26+ tw : ( ) => import ( "@fullcalendar/core/locales/zh-tw" ) ,
27+ ro : ( ) => import ( "@fullcalendar/core/locales/ro" ) ,
28+ ru : ( ) => import ( "@fullcalendar/core/locales/ru" ) ,
29+ ja : ( ) => import ( "@fullcalendar/core/locales/ja" ) ,
30+ "pt_br" : ( ) => import ( "@fullcalendar/core/locales/pt-br" ) ,
31+ uk : ( ) => import ( "@fullcalendar/core/locales/uk" ) ,
32+ en : null
33+ } ;
1834
1935const TPL = /*html*/ `
2036<div class="calendar-view">
@@ -657,31 +673,11 @@ export default class CalendarView extends ViewMode<{}> {
657673
658674}
659675
660- export async function getFullCalendarLocale ( locale : string ) {
661- // Here we hard-code the imports in order to ensure that they are embedded by webpack without having to load all the languages.
662- switch ( locale ) {
663- case "de" :
664- return ( await import ( "@fullcalendar/core/locales/de" ) ) . default ;
665- case "es" :
666- return ( await import ( "@fullcalendar/core/locales/es" ) ) . default ;
667- case "fr" :
668- return ( await import ( "@fullcalendar/core/locales/fr" ) ) . default ;
669- case "cn" :
670- return ( await import ( "@fullcalendar/core/locales/zh-cn" ) ) . default ;
671- case "tw" :
672- return ( await import ( "@fullcalendar/core/locales/zh-tw" ) ) . default ;
673- case "ro" :
674- return ( await import ( "@fullcalendar/core/locales/ro" ) ) . default ;
675- case "ru" :
676- return ( await import ( "@fullcalendar/core/locales/ru" ) ) . default ;
677- case "ja" :
678- return ( await import ( "@fullcalendar/core/locales/ja" ) ) . default ;
679- case "pt_br" :
680- return ( await import ( "@fullcalendar/core/locales/pt-br" ) ) . default ;
681- case "uk" :
682- return ( await import ( "@fullcalendar/core/locales/uk" ) ) . default ;
683- case "en" :
684- default :
685- return undefined ;
676+ export async function getFullCalendarLocale ( locale : LOCALE_IDS ) {
677+ const correspondingLocale = LOCALE_MAPPINGS [ locale ] ;
678+ if ( correspondingLocale ) {
679+ return ( await correspondingLocale ( ) ) . default ;
680+ } else {
681+ return undefined ;
686682 }
687683}
0 commit comments