Skip to content

Build your personal knowledge base with Trilium Notes

feat(ckeditor5): localize the footnote strings through editor.t()

Elian Doran6da4599d5fbd
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index 82a4cfcd3d..e73ae75b84 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -3608,10 +3608,14 @@
"admonition": "Admonition",
"caution": "Caution",
"copy-formatting": "Copy formatting",
+ "footnote": "Footnote",
+ "footnote-widget": "footnote widget",
"important": "Important",
"include-note": "Include note",
+ "insert-footnote-0": "Insert footnote %0",
"keyboard-shortcut": "Keyboard shortcut",
"link-preview": "Link preview",
+ "new-footnote": "New footnote",
"note": "Note",
"tip": "Tip",
"warning": "Warning"
diff --git a/packages/ckeditor5/src/plugins/footnotes/converters.ts b/packages/ckeditor5/src/plugins/footnotes/converters.ts
index 1fdbc42b46..85be6d4613 100644
--- a/packages/ckeditor5/src/plugins/footnotes/converters.ts
+++ b/packages/ckeditor5/src/plugins/footnotes/converters.ts
@@ -9,6 +9,7 @@ import { viewQueryElement } from "./utils.js";
*/
export const defineConverters = (editor: Editor): void => {
const conversion = editor.conversion;
+ const t = editor.t;
/* Attribute conversion */
@@ -66,7 +67,9 @@ export const defineConverters = (editor: Editor): void => {
class: CLASSES.footnoteSection
});
- return toWidget(section, viewWriter, { label: "footnote widget" });
+ // Announced by screen readers when the widget is selected; lowercase to match the
+ // "image widget" / "table widget" labels CKEditor gives its own widgets.
+ return toWidget(section, viewWriter, { label: t("footnote widget") });
}
});
diff --git a/packages/ckeditor5/src/plugins/footnotes/footnote_ui.ts b/packages/ckeditor5/src/plugins/footnotes/footnote_ui.ts
index af0fc63275..e2abc27e9a 100644
--- a/packages/ckeditor5/src/plugins/footnotes/footnote_ui.ts
+++ b/packages/ckeditor5/src/plugins/footnotes/footnote_ui.ts
@@ -16,7 +16,7 @@ export default class FootnoteUI extends Plugin {
public init(): void {
const editor = this.editor;
- const translate = editor.t;
+ const t = editor.t;
editor.ui.componentFactory.add(TOOLBAR_COMPONENT_NAME, (locale) => {
const dropdownView = createDropdown(locale, SplitButtonView);
@@ -28,7 +28,7 @@ export default class FootnoteUI extends Plugin {
}
splitButtonView.set({
- label: translate("Footnote"),
+ label: t("Footnote"),
icon: insertFootnoteIcon,
tooltip: true,
isToggleable: true
@@ -73,12 +73,13 @@ export default class FootnoteUI extends Plugin {
*/
public getDropdownItemsDefinitions(): Collection<ListDropdownItemDefinition> {
const itemDefinitions = new Collection<ListDropdownItemDefinition>();
+ const t = this.editor.t;
itemDefinitions.add({
type: "button",
model: new ViewModel({
commandParam: 0,
- label: "New footnote",
+ label: t("New footnote"),
withText: true
})
});
@@ -104,7 +105,7 @@ export default class FootnoteUI extends Plugin {
type: "button",
model: new ViewModel({
commandParam: index,
- label: `Insert footnote ${index}`,
+ label: t("Insert footnote %0", String(index)),
withText: true
})
});