From 31c5323fd90db3b2145645baa738670cb46aebcf Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Fri, 12 Dec 2025 18:05:10 +0200 Subject: [PATCH] feat(status_bar/language): compact locale name --- apps/client/src/widgets/layout/StatusBar.tsx | 1 + .../src/widgets/ribbon/BasicPropertiesTab.tsx | 7 ++++++- .../options/components/LocaleSelector.tsx | 16 ++++++++++++---- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/apps/client/src/widgets/layout/StatusBar.tsx b/apps/client/src/widgets/layout/StatusBar.tsx index e017728de..3cea9e988 100644 --- a/apps/client/src/widgets/layout/StatusBar.tsx +++ b/apps/client/src/widgets/layout/StatusBar.tsx @@ -41,6 +41,7 @@ function LanguageSwitcher({ note }: StatusBarContext) { icon="bx bx-help-circle" >{t("note_language.help-on-languages")} )} + compact /> ); } diff --git a/apps/client/src/widgets/ribbon/BasicPropertiesTab.tsx b/apps/client/src/widgets/ribbon/BasicPropertiesTab.tsx index 479994ca3..dda9a7830 100644 --- a/apps/client/src/widgets/ribbon/BasicPropertiesTab.tsx +++ b/apps/client/src/widgets/ribbon/BasicPropertiesTab.tsx @@ -330,7 +330,11 @@ function NoteLanguageSwitch({ note }: { note?: FNote | null }) { ); } -export function NoteLanguageSelector({ note, extraChildren }: { note: FNote | null | undefined, extraChildren?: ComponentChildren }) { +export function NoteLanguageSelector({ note, extraChildren, ...restProps }: { + note: FNote | null | undefined, + extraChildren?: ComponentChildren, + compact?: boolean; +}) { const [ modalShown, setModalShown ] = useState(false); const [ languages ] = useTriliumOption("languages"); const DEFAULT_LOCALE = { @@ -357,6 +361,7 @@ export function NoteLanguageSelector({ note, extraChildren }: { note: FNote | nu icon="bx bx-cog" >{t("note_language.configure-languages")} } + {...restProps} /> {createPortal( , diff --git a/apps/client/src/widgets/type_widgets/options/components/LocaleSelector.tsx b/apps/client/src/widgets/type_widgets/options/components/LocaleSelector.tsx index b9b1d8758..c19fdbfac 100644 --- a/apps/client/src/widgets/type_widgets/options/components/LocaleSelector.tsx +++ b/apps/client/src/widgets/type_widgets/options/components/LocaleSelector.tsx @@ -5,13 +5,14 @@ import { useMemo } from "preact/hooks"; import Dropdown from "../../../react/Dropdown"; import { FormDropdownDivider, FormListItem } from "../../../react/FormList"; -export function LocaleSelector({ id, locales, currentValue, onChange, defaultLocale, extraChildren }: { +export function LocaleSelector({ id, locales, currentValue, onChange, defaultLocale, extraChildren, compact }: { id?: string; locales: Locale[], currentValue: string, onChange: (newLocale: string) => void, defaultLocale?: Locale, - extraChildren?: ComponentChildren + extraChildren?: ComponentChildren, + compact?: boolean; }) { const activeLocale = defaultLocale?.id === currentValue ? defaultLocale : locales.find(l => l.id === currentValue); @@ -42,7 +43,7 @@ export function LocaleSelector({ id, locales, currentValue, onChange, defaultLoc }, [ locales ]); return ( - + {processedLocales.map(locale => { if (typeof locale === "object") { return - ) + ); +} + +function getLocaleName(locale: Locale | null | undefined, compact: boolean | undefined) { + if (!locale) return ""; + if (!compact) return locale.name; + if (!locale.id) return "-"; + return locale.id.toLocaleUpperCase(); }