From e08a9e1915339e027d66b853f07812fe0c510446 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 9 Oct 2025 19:28:05 +0300 Subject: [PATCH] chore(client): add Arabic to full calendar --- apps/client/src/services/i18n.spec.ts | 2 +- apps/client/src/widgets/collections/calendar/index.tsx | 7 ++++--- packages/commons/src/lib/i18n.ts | 5 ++++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/apps/client/src/services/i18n.spec.ts b/apps/client/src/services/i18n.spec.ts index e64605949..e40881643 100644 --- a/apps/client/src/services/i18n.spec.ts +++ b/apps/client/src/services/i18n.spec.ts @@ -6,7 +6,7 @@ import { describe, expect, it } from "vitest"; describe("i18n", () => { it("translations are valid JSON", () => { for (const locale of LOCALES) { - if (locale.contentOnly) { + if (locale.contentOnly || locale.id === "en_rtl") { continue; } diff --git a/apps/client/src/widgets/collections/calendar/index.tsx b/apps/client/src/widgets/collections/calendar/index.tsx index c22155585..2d7d77b2e 100644 --- a/apps/client/src/widgets/collections/calendar/index.tsx +++ b/apps/client/src/widgets/collections/calendar/index.tsx @@ -3,8 +3,8 @@ import { ViewModeProps } from "../interface"; import Calendar from "./calendar"; import { useCallback, useEffect, useMemo, useRef, useState } from "preact/hooks"; import "./index.css"; -import { useNoteLabel, useNoteLabelBoolean, useResizeObserver, useSpacedUpdate, useTouchBar, useTriliumEvent, useTriliumOption, useTriliumOptionInt } from "../../react/hooks"; -import { LOCALE_IDS } from "@triliumnext/commons"; +import { useNoteLabel, useNoteLabelBoolean, useResizeObserver, useSpacedUpdate, useTriliumEvent, useTriliumOption, useTriliumOptionInt } from "../../react/hooks"; +import { DISPLAYABLE_LOCALE_IDS, LOCALE_IDS } from "@triliumnext/commons"; import { Calendar as FullCalendar } from "@fullcalendar/core"; import { parseStartEndDateFromEvent, parseStartEndTimeFromEvent } from "./utils"; import dialog from "../../../services/dialog"; @@ -62,7 +62,7 @@ const CALENDAR_VIEWS = [ const SUPPORTED_CALENDAR_VIEW_TYPE = CALENDAR_VIEWS.map(v => v.type); // Here we hard-code the imports in order to ensure that they are embedded by webpack without having to load all the languages. -export const LOCALE_MAPPINGS: Record Promise<{ default: LocaleInput }>) | null> = { +export const LOCALE_MAPPINGS: Record Promise<{ default: LocaleInput }>) | null> = { de: () => import("@fullcalendar/core/locales/de"), es: () => import("@fullcalendar/core/locales/es"), fr: () => import("@fullcalendar/core/locales/fr"), @@ -76,6 +76,7 @@ export const LOCALE_MAPPINGS: Record Promise<{ default: Local uk: () => import("@fullcalendar/core/locales/uk"), en: null, "en_rtl": null, + ar: () => import("@fullcalendar/core/locales/ar") }; export default function CalendarView({ note, noteIds }: ViewModeProps) { diff --git a/packages/commons/src/lib/i18n.ts b/packages/commons/src/lib/i18n.ts index 4de84afeb..8e408f2e6 100644 --- a/packages/commons/src/lib/i18n.ts +++ b/packages/commons/src/lib/i18n.ts @@ -11,7 +11,7 @@ export interface Locale { electronLocale?: "en" | "de" | "es" | "fr" | "zh_CN" | "zh_TW" | "ro" | "af" | "am" | "ar" | "bg" | "bn" | "ca" | "cs" | "da" | "el" | "en_GB" | "es_419" | "et" | "fa" | "fi" | "fil" | "gu" | "he" | "hi" | "hr" | "hu" | "id" | "it" | "ja" | "kn" | "ko" | "lt" | "lv" | "ml" | "mr" | "ms" | "nb" | "nl" | "pl" | "pt_BR" | "pt_PT" | "ru" | "sk" | "sl" | "sr" | "sv" | "sw" | "ta" | "te" | "th" | "tr" | "uk" | "ur" | "vi"; } -const UNSORTED_LOCALES: Locale[] = [ +const UNSORTED_LOCALES = [ { id: "cn", name: "简体中文", electronLocale: "zh_CN" }, { id: "de", name: "Deutsch", electronLocale: "de" }, { id: "en", name: "English", electronLocale: "en" }, @@ -73,4 +73,7 @@ const UNSORTED_LOCALES: Locale[] = [ export const LOCALES: Locale[] = Array.from(UNSORTED_LOCALES) .sort((a, b) => a.name.localeCompare(b.name)); +/** A type containing a string union of all the supported locales, including those that are content-only. */ export type LOCALE_IDS = typeof UNSORTED_LOCALES[number]["id"]; +/** A type containing a string union of all the supported locales that are not content-only (i.e. can be used as the UI language). */ +export type DISPLAYABLE_LOCALE_IDS = Exclude["id"];