From 80ee94da732cbe33f177bbb3584695771c906d85 Mon Sep 17 00:00:00 2001 From: lucaronin Date: Sat, 6 Jun 2026 10:35:21 +0200 Subject: [PATCH] fix: localize highlight toolbar copy --- lara.lock | 2 + src/components/SingleEditorView.tsx | 5 ++- src/components/tolariaEditorFormatting.tsx | 51 +++++++++++++++------- src/lib/locales/be-BY.json | 2 + src/lib/locales/be-Latn.json | 2 + src/lib/locales/de-DE.json | 2 + src/lib/locales/en.json | 2 + src/lib/locales/es-419.json | 2 + src/lib/locales/es-ES.json | 2 + src/lib/locales/fr-FR.json | 2 + src/lib/locales/id-ID.json | 2 + src/lib/locales/it-IT.json | 2 + src/lib/locales/ja-JP.json | 2 + src/lib/locales/ko-KR.json | 2 + src/lib/locales/pl-PL.json | 2 + src/lib/locales/pt-BR.json | 2 + src/lib/locales/pt-PT.json | 2 + src/lib/locales/ru-RU.json | 2 + src/lib/locales/vi.json | 2 + src/lib/locales/zh-CN.json | 2 + src/lib/locales/zh-TW.json | 2 + 21 files changed, 78 insertions(+), 16 deletions(-) diff --git a/lara.lock b/lara.lock index 1a844b13..ef2088b4 100644 --- a/lara.lock +++ b/lara.lock @@ -591,6 +591,8 @@ files: editor.toolbar.exportPdf: 7a39acf8742a59d1a4f7ae064b6219a0 editor.toolbar.moreActions: 89e19353176b94068dec4c768c25e70b editor.toolbar.openProperties: 948b90b60b8ce827f179e8c5b85b112e + editor.formatting.highlight: 0b90582f4589d84be89f5b847d4d1ed1 + editor.formatting.highlightTooltip: c27173fea9ec1718030c5fa8440b2c78 editor.whiteboard.enterFullscreen: 606bf766125ecff4b33ca98122222c72 editor.whiteboard.exitFullscreen: afd0a0414d79d047f00319921e4d4944 editor.exportPdf.unavailable: 2fce9834984172b64b66767485d815e9 diff --git a/src/components/SingleEditorView.tsx b/src/components/SingleEditorView.tsx index a55dc431..5080c260 100644 --- a/src/components/SingleEditorView.tsx +++ b/src/components/SingleEditorView.tsx @@ -1111,6 +1111,7 @@ function useSuggestionMenuItems(options: { } type EditorInteractionControllersProps = ReturnType & { + locale: AppLocale runEditorAction: (action: SuggestionAction) => void vaultPath?: string } @@ -1120,6 +1121,7 @@ function EditorInteractionControllers({ getPersonMentionItems, getSlashMenuItems, getWikilinkItems, + locale, runEditorAction, vaultPath, }: EditorInteractionControllersProps) { @@ -1128,7 +1130,7 @@ function EditorInteractionControllers({ ( - + )} floatingUIOptions={{ elementProps: { @@ -1372,6 +1374,7 @@ export function SingleEditorView({ editor, entries, onNavigateWikilink, onChange > diff --git a/src/components/tolariaEditorFormatting.tsx b/src/components/tolariaEditorFormatting.tsx index f1bfd647..b9846a5d 100644 --- a/src/components/tolariaEditorFormatting.tsx +++ b/src/components/tolariaEditorFormatting.tsx @@ -59,6 +59,7 @@ import { filterTolariaFormattingToolbarItems, getTolariaBlockTypeSelectItems, } from './tolariaEditorFormattingConfig' +import { translate, type AppLocale } from '../lib/i18n' import { useBlockNoteFormattingToolbarHoverGuard } from './blockNoteFormattingToolbarHoverGuard' import { openEditorAttachmentOrUrl } from './editorAttachmentActions' import { @@ -190,13 +191,8 @@ const TOLARIA_BASIC_TEXT_STYLE_TOOLTIPS = { mainTooltip: 'Inline code (persists in markdown)', secondaryTooltip: '`code`', }, - [MARKDOWN_HIGHLIGHT_STYLE]: { - label: 'Highlight', - mainTooltip: 'Highlight (persists in markdown)', - secondaryTooltip: '==highlight==', - }, } satisfies Record< - TolariaBasicTextStyle, + Exclude, { label: string; mainTooltip: string; secondaryTooltip: string } > @@ -497,8 +493,10 @@ function updateSelectedBlocksToType( function TolariaBasicTextStyleButton({ basicTextStyle, + locale = 'en', }: { basicTextStyle: TolariaBasicTextStyle + locale?: AppLocale }) { const Components = useComponentsContext()! const editor = useBlockNoteEditor< @@ -519,11 +517,7 @@ function TolariaBasicTextStyleButton({ if (buttonState === undefined) return null const Icon = Reflect.get(TOLARIA_BASIC_TEXT_STYLE_ICONS, basicTextStyle) as PhosphorIcon - const copy = Reflect.get(TOLARIA_BASIC_TEXT_STYLE_TOOLTIPS, basicTextStyle) as { - label: string - mainTooltip: string - secondaryTooltip: string - } + const copy = basicTextStyleCopy(basicTextStyle, locale) return ( String(item.key) === 'strikeStyleButton', ) @@ -674,12 +687,13 @@ function insertExtraTextStyleButtons(items: ReactElement[]) { , ...items.slice(strikeButtonIndex + 1), ] } -function getTolariaFormattingToolbarItems(vaultPath?: string) { +function getTolariaFormattingToolbarItems(vaultPath: string | undefined, locale: AppLocale) { return insertExtraTextStyleButtons( replaceToolbarControls( filterTolariaFormattingToolbarItems( @@ -687,11 +701,18 @@ function getTolariaFormattingToolbarItems(vaultPath?: string) { ), vaultPath, ), + locale, ) } -export function TolariaFormattingToolbar({ vaultPath }: { vaultPath?: string } = {}) { - return {getTolariaFormattingToolbarItems(vaultPath)} +export function TolariaFormattingToolbar({ + locale = 'en', + vaultPath, +}: { + locale?: AppLocale + vaultPath?: string +} = {}) { + return {getTolariaFormattingToolbarItems(vaultPath, locale)} } export function TolariaFormattingToolbarController(props: { diff --git a/src/lib/locales/be-BY.json b/src/lib/locales/be-BY.json index aae73ad9..c80bb82e 100644 --- a/src/lib/locales/be-BY.json +++ b/src/lib/locales/be-BY.json @@ -589,6 +589,8 @@ "editor.toolbar.exportPdf": "Экспартаваць нататку ў фармаце PDF", "editor.toolbar.moreActions": "Больш дзеянняў", "editor.toolbar.openProperties": "Адкрыць уласцівасці", + "editor.formatting.highlight": "Вылучэнне", + "editor.formatting.highlightTooltip": "Вылучэнне (захоўваецца ў Markdown)", "editor.whiteboard.enterFullscreen": "Разгарнуць дошку", "editor.whiteboard.exitFullscreen": "Выйсці з поўнаэкраннай дошкі", "editor.exportPdf.unavailable": "Адкрыйце нататку Markdown перад экспартам у PDF.", diff --git a/src/lib/locales/be-Latn.json b/src/lib/locales/be-Latn.json index cd2d0bff..f9c74645 100644 --- a/src/lib/locales/be-Latn.json +++ b/src/lib/locales/be-Latn.json @@ -591,6 +591,8 @@ "editor.toolbar.exportPdf": "Ekspartavać natatku ŭ farmacie PDF", "editor.toolbar.moreActions": "Boĺš dziejanniaŭ", "editor.toolbar.openProperties": "Adkryć ulascivasci", + "editor.formatting.highlight": "Vylučennie", + "editor.formatting.highlightTooltip": "Vylučennie (zachoŭvajecca ŭ Markdown)", "editor.whiteboard.enterFullscreen": "Pašyryć došku", "editor.whiteboard.exitFullscreen": "Vyjsci z poŭnaekrannaj doški", "editor.exportPdf.unavailable": "Adkryjcie natatku Markdown pierad ekspartam u PDF.", diff --git a/src/lib/locales/de-DE.json b/src/lib/locales/de-DE.json index e6149ffb..b67c3d7c 100644 --- a/src/lib/locales/de-DE.json +++ b/src/lib/locales/de-DE.json @@ -589,6 +589,8 @@ "editor.toolbar.exportPdf": "Notiz als PDF exportieren", "editor.toolbar.moreActions": "Weitere Notizaktionen", "editor.toolbar.openProperties": "Eigenschaften-Panel öffnen", + "editor.formatting.highlight": "Hervorheben", + "editor.formatting.highlightTooltip": "Hervorhebung (bleibt in Markdown erhalten)", "editor.whiteboard.enterFullscreen": "Whiteboard erweitern", "editor.whiteboard.exitFullscreen": "Vollbild-Whiteboard verlassen", "editor.exportPdf.unavailable": "Öffne eine Markdown-Notiz, bevor du sie als PDF exportierst.", diff --git a/src/lib/locales/en.json b/src/lib/locales/en.json index 0f8bcc0a..24972ed6 100644 --- a/src/lib/locales/en.json +++ b/src/lib/locales/en.json @@ -589,6 +589,8 @@ "editor.toolbar.exportPdf": "Export note as PDF", "editor.toolbar.moreActions": "More note actions", "editor.toolbar.openProperties": "Open the properties panel", + "editor.formatting.highlight": "Highlight", + "editor.formatting.highlightTooltip": "Highlight (persists in markdown)", "editor.whiteboard.enterFullscreen": "Expand whiteboard", "editor.whiteboard.exitFullscreen": "Exit fullscreen whiteboard", "editor.exportPdf.unavailable": "Open a Markdown note before exporting a PDF.", diff --git a/src/lib/locales/es-419.json b/src/lib/locales/es-419.json index 24b782f1..ada378a3 100644 --- a/src/lib/locales/es-419.json +++ b/src/lib/locales/es-419.json @@ -589,6 +589,8 @@ "editor.toolbar.exportPdf": "Exportar nota como PDF", "editor.toolbar.moreActions": "Más acciones de nota", "editor.toolbar.openProperties": "Abrir el panel de propiedades", + "editor.formatting.highlight": "Resaltar", + "editor.formatting.highlightTooltip": "Resaltado (persiste en Markdown)", "editor.whiteboard.enterFullscreen": "Expandir pizarra", "editor.whiteboard.exitFullscreen": "Salir de la pizarra en pantalla completa", "editor.exportPdf.unavailable": "Abre una nota de Markdown antes de exportar un PDF.", diff --git a/src/lib/locales/es-ES.json b/src/lib/locales/es-ES.json index 104eb500..184fa1df 100644 --- a/src/lib/locales/es-ES.json +++ b/src/lib/locales/es-ES.json @@ -589,6 +589,8 @@ "editor.toolbar.exportPdf": "Exportar nota como PDF", "editor.toolbar.moreActions": "Más acciones de nota", "editor.toolbar.openProperties": "Abrir el panel de propiedades", + "editor.formatting.highlight": "Resaltado", + "editor.formatting.highlightTooltip": "Resaltado (persiste en Markdown)", "editor.whiteboard.enterFullscreen": "Expandir pizarra", "editor.whiteboard.exitFullscreen": "Salir de la pizarra en pantalla completa", "editor.exportPdf.unavailable": "Abre una nota de Markdown antes de exportar un PDF.", diff --git a/src/lib/locales/fr-FR.json b/src/lib/locales/fr-FR.json index d116027d..aae165af 100644 --- a/src/lib/locales/fr-FR.json +++ b/src/lib/locales/fr-FR.json @@ -589,6 +589,8 @@ "editor.toolbar.exportPdf": "Exporter la note au format PDF", "editor.toolbar.moreActions": "Autres actions de note", "editor.toolbar.openProperties": "Ouvrir le panneau des propriétés", + "editor.formatting.highlight": "Surligner", + "editor.formatting.highlightTooltip": "Surlignage (persiste dans le Markdown)", "editor.whiteboard.enterFullscreen": "Agrandir le tableau blanc", "editor.whiteboard.exitFullscreen": "Quitter le tableau blanc en plein écran", "editor.exportPdf.unavailable": "Ouvrez une note Markdown avant d'exporter un PDF.", diff --git a/src/lib/locales/id-ID.json b/src/lib/locales/id-ID.json index 6274cbb2..0f397958 100644 --- a/src/lib/locales/id-ID.json +++ b/src/lib/locales/id-ID.json @@ -589,6 +589,8 @@ "editor.toolbar.exportPdf": "Ekspor catatan sebagai PDF", "editor.toolbar.moreActions": "Tindakan catatan lainnya", "editor.toolbar.openProperties": "Buka panel properti", + "editor.formatting.highlight": "Sorot", + "editor.formatting.highlightTooltip": "Sorot (bertahan dalam markdown)", "editor.whiteboard.enterFullscreen": "Perluas papan tulis", "editor.whiteboard.exitFullscreen": "Keluar dari papan tulis layar penuh", "editor.exportPdf.unavailable": "Buka catatan Markdown sebelum mengekspor PDF.", diff --git a/src/lib/locales/it-IT.json b/src/lib/locales/it-IT.json index f0edc283..a0ee1b1c 100644 --- a/src/lib/locales/it-IT.json +++ b/src/lib/locales/it-IT.json @@ -589,6 +589,8 @@ "editor.toolbar.exportPdf": "Esporta nota in PDF", "editor.toolbar.moreActions": "Altre azioni della nota", "editor.toolbar.openProperties": "Apri il pannello delle proprietà", + "editor.formatting.highlight": "Evidenzia", + "editor.formatting.highlightTooltip": "Evidenziazione (persiste in markdown)", "editor.whiteboard.enterFullscreen": "Espandi la lavagna", "editor.whiteboard.exitFullscreen": "Esci dalla lavagna a schermo intero", "editor.exportPdf.unavailable": "Apri una nota Markdown prima di esportare un PDF.", diff --git a/src/lib/locales/ja-JP.json b/src/lib/locales/ja-JP.json index c79ac89a..a5a45837 100644 --- a/src/lib/locales/ja-JP.json +++ b/src/lib/locales/ja-JP.json @@ -589,6 +589,8 @@ "editor.toolbar.exportPdf": "ノートをPDFとしてエクスポート", "editor.toolbar.moreActions": "その他のノート操作", "editor.toolbar.openProperties": "プロパティパネルを開く", + "editor.formatting.highlight": "ハイライト", + "editor.formatting.highlightTooltip": "ハイライト(Markdownで保持)", "editor.whiteboard.enterFullscreen": "ホワイトボードを展開", "editor.whiteboard.exitFullscreen": "フルスクリーンホワイトボードを終了", "editor.exportPdf.unavailable": "PDFをエクスポートする前に、Markdownノートを開いてください。", diff --git a/src/lib/locales/ko-KR.json b/src/lib/locales/ko-KR.json index 210a82b3..d7e953e9 100644 --- a/src/lib/locales/ko-KR.json +++ b/src/lib/locales/ko-KR.json @@ -589,6 +589,8 @@ "editor.toolbar.exportPdf": "노트를 PDF로 내보내기", "editor.toolbar.moreActions": "추가 노트 작업", "editor.toolbar.openProperties": "속성 패널 열기", + "editor.formatting.highlight": "강조", + "editor.formatting.highlightTooltip": "강조 표시(마크다운에 유지)", "editor.whiteboard.enterFullscreen": "화이트보드 펼치기", "editor.whiteboard.exitFullscreen": "전체 화면 화이트보드에서 나가기", "editor.exportPdf.unavailable": "PDF로 내보내기 전에 Markdown 노트를 여세요.", diff --git a/src/lib/locales/pl-PL.json b/src/lib/locales/pl-PL.json index 69b6f982..dcc7f22b 100644 --- a/src/lib/locales/pl-PL.json +++ b/src/lib/locales/pl-PL.json @@ -589,6 +589,8 @@ "editor.toolbar.exportPdf": "Eksportuj notatkę jako PDF", "editor.toolbar.moreActions": "Więcej działań notatki", "editor.toolbar.openProperties": "Otwórz panel właściwości", + "editor.formatting.highlight": "Wyróżnienie", + "editor.formatting.highlightTooltip": "Wyróżnienie (zachowuje się w Markdownie)", "editor.whiteboard.enterFullscreen": "Rozwiń tablicę", "editor.whiteboard.exitFullscreen": "Wyjdź z tablicy pełnoekranowej", "editor.exportPdf.unavailable": "Otwórz notatkę Markdown przed wyeksportowaniem pliku PDF.", diff --git a/src/lib/locales/pt-BR.json b/src/lib/locales/pt-BR.json index 604e2620..e5b17020 100644 --- a/src/lib/locales/pt-BR.json +++ b/src/lib/locales/pt-BR.json @@ -589,6 +589,8 @@ "editor.toolbar.exportPdf": "Exportar nota como PDF", "editor.toolbar.moreActions": "Mais ações da nota", "editor.toolbar.openProperties": "Abrir o painel de propriedades", + "editor.formatting.highlight": "Destaque", + "editor.formatting.highlightTooltip": "Destaque (persiste no markdown)", "editor.whiteboard.enterFullscreen": "Expandir quadro branco", "editor.whiteboard.exitFullscreen": "Sair do quadro branco em tela cheia", "editor.exportPdf.unavailable": "Abra uma nota Markdown antes de exportar um PDF.", diff --git a/src/lib/locales/pt-PT.json b/src/lib/locales/pt-PT.json index a8883cbb..6510bfee 100644 --- a/src/lib/locales/pt-PT.json +++ b/src/lib/locales/pt-PT.json @@ -589,6 +589,8 @@ "editor.toolbar.exportPdf": "Exportar nota como PDF", "editor.toolbar.moreActions": "Mais ações da nota", "editor.toolbar.openProperties": "Abrir o painel de propriedades", + "editor.formatting.highlight": "Destaque", + "editor.formatting.highlightTooltip": "Destaque (persiste em markdown)", "editor.whiteboard.enterFullscreen": "Expandir quadro branco", "editor.whiteboard.exitFullscreen": "Sair do quadro branco em ecrã inteiro", "editor.exportPdf.unavailable": "Abra uma nota Markdown antes de exportar um PDF.", diff --git a/src/lib/locales/ru-RU.json b/src/lib/locales/ru-RU.json index 3aedb2cf..ccc1aefa 100644 --- a/src/lib/locales/ru-RU.json +++ b/src/lib/locales/ru-RU.json @@ -589,6 +589,8 @@ "editor.toolbar.exportPdf": "Экспортировать заметку в формате PDF", "editor.toolbar.moreActions": "Другие действия с заметкой", "editor.toolbar.openProperties": "Открыть панель свойств", + "editor.formatting.highlight": "Выделение", + "editor.formatting.highlightTooltip": "Выделение (сохраняется в Markdown)", "editor.whiteboard.enterFullscreen": "Развернуть доску", "editor.whiteboard.exitFullscreen": "Выйти из полноэкранной доски", "editor.exportPdf.unavailable": "Откройте заметку Markdown перед экспортом в PDF.", diff --git a/src/lib/locales/vi.json b/src/lib/locales/vi.json index c7dbaadd..97f9ccbd 100644 --- a/src/lib/locales/vi.json +++ b/src/lib/locales/vi.json @@ -589,6 +589,8 @@ "editor.toolbar.exportPdf": "Xuất ghi chú dưới dạng PDF", "editor.toolbar.moreActions": "Thêm hành động ghi chú", "editor.toolbar.openProperties": "Mở bảng thuộc tính", + "editor.formatting.highlight": "Đánh dấu", + "editor.formatting.highlightTooltip": "Đánh dấu (duy trì trong markdown)", "editor.whiteboard.enterFullscreen": "Mở rộng bảng trắng", "editor.whiteboard.exitFullscreen": "Thoát chế độ bảng trắng toàn màn hình", "editor.exportPdf.unavailable": "Mở ghi chú Markdown trước khi xuất PDF.", diff --git a/src/lib/locales/zh-CN.json b/src/lib/locales/zh-CN.json index ccfb1cbc..da29fe70 100644 --- a/src/lib/locales/zh-CN.json +++ b/src/lib/locales/zh-CN.json @@ -589,6 +589,8 @@ "editor.toolbar.exportPdf": "将笔记导出为 PDF", "editor.toolbar.moreActions": "更多笔记操作", "editor.toolbar.openProperties": "打开属性面板", + "editor.formatting.highlight": "高亮", + "editor.formatting.highlightTooltip": "高亮(在 Markdown 中保留)", "editor.whiteboard.enterFullscreen": "展开白板", "editor.whiteboard.exitFullscreen": "退出全屏白板", "editor.exportPdf.unavailable": "在导出 PDF 之前,请先打开 Markdown 笔记。", diff --git a/src/lib/locales/zh-TW.json b/src/lib/locales/zh-TW.json index 53c38731..a484f3b2 100644 --- a/src/lib/locales/zh-TW.json +++ b/src/lib/locales/zh-TW.json @@ -589,6 +589,8 @@ "editor.toolbar.exportPdf": "將筆記匯出為 PDF", "editor.toolbar.moreActions": "更多筆記操作", "editor.toolbar.openProperties": "開啟屬性面板", + "editor.formatting.highlight": "醒目提示", + "editor.formatting.highlightTooltip": "醒目提示(在 Markdown 中保留)", "editor.whiteboard.enterFullscreen": "展開白板", "editor.whiteboard.exitFullscreen": "退出全螢幕白板", "editor.exportPdf.unavailable": "在匯出 PDF 之前,請先開啟 Markdown 筆記。",