Skip to content

Build your personal knowledge base with Trilium Notes

feat(ckeditor5): move the link embed strings off the translation-key bridge

Elian Doranc6e34a191542
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index bd091fc8e5..bf61a4cce9 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -2685,18 +2685,7 @@
"failed_to_open": "Failed to open link '{{- href}}': {{- message}}"
},
"link_embed": {
- "play_video": "Play video",
- "title": "Link preview",
- "url": "URL",
- "insert": "Insert",
- "display": "Display",
- "mode_inline": "Inline",
- "mode_card": "Card",
- "mode_embed": "Embed",
- "mode_plain": "Plain link",
- "edit_title": "Edit title",
- "title_label": "Title",
- "save": "Save"
+ "play_video": "Play video"
},
"link_context_menu": {
"open_note_in_new_tab": "Open note in a new tab",
@@ -3585,6 +3574,7 @@
"align-text-to-the-right": "Align text to the right",
"anchor": "Anchor",
"bulleted-list": "Bulleted list",
+ "card": "Card",
"caution": "Caution",
"click-on-the-arrow-or-press-0-to-collapse-expand": "Click on the arrow or press %0 to collapse/expand.",
"collapsible-block": "Collapsible block",
@@ -3598,11 +3588,14 @@
"cut-paste-selection-to-sub-note": "Cut & paste selection to sub-note",
"date-time": "Date time",
"decrease-the-indentation-of-the-current-block": "Decrease the indentation of the current block.",
+ "display": "Display",
"display-mode": "Display mode",
"display-the-content-of-another-note-in-this-note": "Display the content of another note in this note",
"download-image": "Download image",
"drag-to-reposition-the-collapsible-block": "Drag to reposition the collapsible block",
"edit-task-states": "Edit task states",
+ "edit-title": "Edit title",
+ "embed": "Embed",
"equation-preview": "Equation preview",
"error-rendering-equation": "Error rendering equation",
"footnote": "Footnote",
@@ -3612,6 +3605,7 @@
"include-note": "Include note",
"increase-the-indentation-of-the-current-block": "Increase the indentation of the current block.",
"indent": "Indent",
+ "inline": "Inline",
"insert-a-0-mermaid-diagram-template": "Insert a \"%0\" Mermaid diagram template",
"insert-a-block-of-preformatted-code": "Insert a block of preformatted code.",
"insert-a-horizontal-rule": "Insert a horizontal rule.",
@@ -3634,6 +3628,8 @@
"justify-text-alignment": "Justify text alignment",
"keyboard-shortcut": "Keyboard shortcut",
"latex": "LaTeX",
+ "link-embed-widget": "link embed widget",
+ "link-mention-widget": "link mention widget",
"link-preview": "Link preview",
"markdown-import": "Markdown import",
"markdown-import-from-clipboard": "Markdown import from clipboard",
@@ -3650,6 +3646,7 @@
"note": "Note",
"numbered-list": "Numbered list",
"outdent": "Outdent",
+ "plain-link": "Plain link",
"preview": "Preview",
"quote-a-passage-from-another-source": "Quote a passage from another source.",
"read-more-about-mermaid-diagram-syntax": "Read more about Mermaid diagram syntax",
@@ -3662,12 +3659,14 @@
"task-state": "Task state:",
"template": "Template",
"tip": "Tip",
+ "title": "Title",
"to-do-list": "To-do list",
"toggle-collapsible-block": "Toggle collapsible block",
"turn-the-current-block-into-a-heading": "Turn the current block into a heading.",
"turn-the-current-block-into-a-paragraph": "Turn the current block into a paragraph.",
"type-the-content-here": "Type the content here...",
"undefined-custom-task-state": "Undefined custom task state",
+ "url": "URL",
"warning": "Warning"
},
"task-state-dropped-title": "Invalid task states",
diff --git a/packages/ckeditor5/src/plugins/link_embed/link_embed.ts b/packages/ckeditor5/src/plugins/link_embed/link_embed.ts
index 052ff251bb..48d651ee40 100644
--- a/packages/ckeditor5/src/plugins/link_embed/link_embed.ts
+++ b/packages/ckeditor5/src/plugins/link_embed/link_embed.ts
@@ -6,6 +6,7 @@ import LinkEmbedUI from './link_embed_ui.js';
export {
CHANGE_LINK_DISPLAY_COMMAND,
CHANGE_LINK_PREVIEW_TITLE_COMMAND,
+ getLinkDisplayModeLabel,
LINK_DISPLAY_MODES,
LINK_EMBED_COMMAND,
REMOVE_LINK_EMBED_COMMAND,
diff --git a/packages/ckeditor5/src/plugins/link_embed/link_embed_commands.ts b/packages/ckeditor5/src/plugins/link_embed/link_embed_commands.ts
index ec8d042f70..094d3f7191 100644
--- a/packages/ckeditor5/src/plugins/link_embed/link_embed_commands.ts
+++ b/packages/ckeditor5/src/plugins/link_embed/link_embed_commands.ts
@@ -7,15 +7,41 @@ export const REMOVE_LINK_EMBED_COMMAND = 'removeLinkEmbed';
export const CHANGE_LINK_PREVIEW_TITLE_COMMAND = 'changeLinkPreviewTitle';
export const LINK_DISPLAY_MODES = [
- { value: 'inline', label: 'Inline', labelKey: 'link_embed.mode_inline' },
- { value: 'card', label: 'Card', labelKey: 'link_embed.mode_card' },
- { value: 'embed', label: 'Embed', labelKey: 'link_embed.mode_embed' },
+ 'inline',
+ 'card',
+ 'embed',
// The way out of the preview system: an ordinary <a> link, no widget. Offered in the same
// dropdowns as the real modes so "back to a normal URL" is found where the user looks for it.
- { value: 'plain', label: 'Plain link', labelKey: 'link_embed.mode_plain' }
+ 'plain'
] as const;
-export type LinkDisplayMode = typeof LINK_DISPLAY_MODES[number]['value'];
+export type LinkDisplayMode = typeof LINK_DISPLAY_MODES[number];
+
+/**
+ * The user-facing name of a display mode, as shown by the insert form's dropdown and the widget
+ * toolbar's.
+ *
+ * A switch rather than a table of labels, so that each one is written as a literal argument of a
+ * `t()` call: that is how the messages this package owns are discovered (see `messages.ts`) and a
+ * label tucked away in a table would be invisible to translators.
+ *
+ * @param t the editor's translation function.
+ * @param mode the display mode; an unrecognized one has no label and is returned as-is.
+ */
+export function getLinkDisplayModeLabel(t: (message: string) => string, mode: LinkDisplayMode): string {
+ switch (mode) {
+ case 'inline':
+ return t('Inline');
+ case 'card':
+ return t('Card');
+ case 'embed':
+ return t('Embed');
+ case 'plain':
+ return t('Plain link');
+ default:
+ return mode;
+ }
+}
/**
* What a URL must look like before any conversion — automatic or command-driven — considers turning
diff --git a/packages/ckeditor5/src/plugins/link_embed/link_embed_editing.ts b/packages/ckeditor5/src/plugins/link_embed/link_embed_editing.ts
index 5dbf584c2f..5f8bd39147 100644
--- a/packages/ckeditor5/src/plugins/link_embed/link_embed_editing.ts
+++ b/packages/ckeditor5/src/plugins/link_embed/link_embed_editing.ts
@@ -122,7 +122,9 @@ export default class LinkEmbedEditing extends Plugin {
// widget drag handle — the same one tables use. Without a handle the user grabs the
// preview's own content and the browser's native drag tears the image and text apart;
// the handle moves the whole widget atomically instead.
- return toWidget(section, writer, { label: 'link embed widget', hasSelectionHandle: true });
+ // The label is announced by screen readers; lowercase to match the "image widget" /
+ // "table widget" labels CKEditor gives its own widgets.
+ return toWidget(section, writer, { label: editor.t('link embed widget'), hasSelectionHandle: true });
}
});
@@ -178,7 +180,7 @@ export default class LinkEmbedEditing extends Plugin {
});
writer.insert(writer.createPositionAt(span, 0), inner);
- return toWidget(span, writer, { label: 'link mention widget', hasSelectionHandle: false });
+ return toWidget(span, writer, { label: editor.t('link mention widget'), hasSelectionHandle: false });
}
});
}
diff --git a/packages/ckeditor5/src/plugins/link_embed/link_embed_form.spec.ts b/packages/ckeditor5/src/plugins/link_embed/link_embed_form.spec.ts
index 83c26b346c..805423b482 100644
--- a/packages/ckeditor5/src/plugins/link_embed/link_embed_form.spec.ts
+++ b/packages/ckeditor5/src/plugins/link_embed/link_embed_form.spec.ts
@@ -103,16 +103,17 @@ describe("LinkEmbedFormView", () => {
expect(document.activeElement).toBe(form.urlInputView.fieldView.element);
});
- it("resolves its labels through the host's translation bridge when there is one", async () => {
+ it("resolves its labels through the editor's dictionary when there is one", async () => {
+ // Keyed by `en`, the language the editor resolves messages under when none is configured.
editor = await createTestEditor(
[Essentials, Paragraph, Link, Undo, LinkEmbed],
- { translate: (key: string) => `translated:${key}` } as unknown as Parameters<typeof createTestEditor>[1]
+ { translations: [ {}, { en: { dictionary: { "URL": "Adresă", "Insert": "Inserează" } } } ] }
);
setModelData(editor.model, "<paragraph>[]</paragraph>");
const form = openForm();
- expect(form.urlInputView.label).toBe("translated:link_embed.url");
- expect(form.insertButtonView.label).toBe("translated:link_embed.insert");
+ expect(form.urlInputView.label).toBe("Adresă");
+ expect(form.insertButtonView.label).toBe("Inserează");
});
// -----------------------------------------------------------------------
diff --git a/packages/ckeditor5/src/plugins/link_embed/link_embed_form.ts b/packages/ckeditor5/src/plugins/link_embed/link_embed_form.ts
index 35c8424c1a..91dbac3cd4 100644
--- a/packages/ckeditor5/src/plugins/link_embed/link_embed_form.ts
+++ b/packages/ckeditor5/src/plugins/link_embed/link_embed_form.ts
@@ -20,10 +20,10 @@ import {
ViewModel
} from "ckeditor5";
-import { LINK_DISPLAY_MODES, type LinkDisplayMode } from "./link_embed_commands.js";
+import { getLinkDisplayModeLabel, LINK_DISPLAY_MODES, type LinkDisplayMode } from "./link_embed_commands.js";
-/** Resolves a translation key, falling back to the given English text. See `translate.ts`. */
-type Translate = (key: string, fallback: string) => string;
+/** The editor's translation function, taking an English message id. */
+type Translate = (message: string) => string;
/**
* The balloon form behind the "Link preview" toolbar button: a URL field, a display-mode selector
@@ -54,7 +54,7 @@ export default class LinkEmbedFormView extends View {
private readonly _focusables = new ViewCollection<FocusableView>();
private readonly _focusCycler: FocusCycler;
- constructor(locale: Locale, translate: Translate) {
+ constructor(locale: Locale, t: Translate) {
super(locale);
this.set("url", "");
@@ -62,9 +62,9 @@ export default class LinkEmbedFormView extends View {
this.set("embedAvailable", false);
this.set("isFetching", false);
- this.urlInputView = this._createUrlInput(locale, translate);
- this.modeDropdownView = this._createModeDropdown(locale, translate);
- this.insertButtonView = this._createInsertButton(locale, translate);
+ this.urlInputView = this._createUrlInput(locale, t);
+ this.modeDropdownView = this._createModeDropdown(locale, t);
+ this.insertButtonView = this._createInsertButton(locale, t);
this.setTemplate({
tag: "form",
@@ -77,7 +77,7 @@ export default class LinkEmbedFormView extends View {
{
tag: "div",
attributes: { class: ["ck", "ck-link-embed-form__heading"] },
- children: [{ text: translate("link_embed.title", "Link preview") }]
+ children: [{ text: t("Link preview") }]
},
this.urlInputView,
{
@@ -140,9 +140,9 @@ export default class LinkEmbedFormView extends View {
this._focusCycler.focusFirst();
}
- private _createUrlInput(locale: Locale, translate: Translate) {
+ private _createUrlInput(locale: Locale, t: Translate) {
const urlInput = new LabeledFieldView(locale, createLabeledInputText);
- urlInput.label = translate("link_embed.url", "URL");
+ urlInput.label = t("URL");
urlInput.fieldView.placeholder = "http://";
// Two-way: the field drives `url`, and reset() drives the field.
@@ -156,29 +156,29 @@ export default class LinkEmbedFormView extends View {
return urlInput;
}
- private _createModeDropdown(locale: Locale, translate: Translate) {
+ private _createModeDropdown(locale: Locale, t: Translate) {
const dropdown = createDropdown(locale, DropdownButtonView);
dropdown.buttonView.set({ withText: true, tooltip: true });
- dropdown.buttonView.bind("label").to(this, "mode", (mode) => modeLabel(mode, translate));
+ dropdown.buttonView.bind("label").to(this, "mode", (mode) => getLinkDisplayModeLabel(t, mode));
dropdown.bind("isEnabled").to(this, "isFetching", (isFetching) => !isFetching);
const items = new Collection<ListDropdownButtonDefinition>();
- for (const modeDef of LINK_DISPLAY_MODES) {
+ for (const mode of LINK_DISPLAY_MODES) {
const definition: ListDropdownButtonDefinition = {
type: "button",
model: new ViewModel({
- _displayMode: modeDef.value,
- label: translate(modeDef.labelKey, modeDef.label),
+ _displayMode: mode,
+ label: getLinkDisplayModeLabel(t, mode),
role: "menuitemradio",
withText: true
})
};
- definition.model.bind("isOn").to(this, "mode", (mode) => mode === modeDef.value);
+ definition.model.bind("isOn").to(this, "mode", (current) => current === mode);
// A player only exists for a URL that has one.
- if (modeDef.value === "embed") {
+ if (mode === "embed") {
definition.model.bind("isVisible").to(this, "embedAvailable");
}
@@ -193,12 +193,12 @@ export default class LinkEmbedFormView extends View {
return dropdown;
}
- private _createInsertButton(locale: Locale, translate: Translate) {
+ private _createInsertButton(locale: Locale, t: Translate) {
const button = new ButtonView(locale);
// A text button, like the Insert button of the editor's own link form.
button.set({
- label: translate("link_embed.insert", "Insert"),
+ label: t("Insert"),
withText: true,
type: "submit",
class: "ck-button-action ck-button-bold"
@@ -214,10 +214,3 @@ export default class LinkEmbedFormView extends View {
return button;
}
}
-
-/** A display mode's label, in the user's language. */
-function modeLabel(mode: LinkDisplayMode, translate: Translate): string {
- const found = LINK_DISPLAY_MODES.find((modeDef) => modeDef.value === mode);
- /* v8 ignore next -- `mode` is only ever set from LINK_DISPLAY_MODES, so the fallback is unreachable */
- return found ? translate(found.labelKey, found.label) : String(mode);
-}
diff --git a/packages/ckeditor5/src/plugins/link_embed/link_embed_title_form.spec.ts b/packages/ckeditor5/src/plugins/link_embed/link_embed_title_form.spec.ts
index 3472756e2e..af08fd9568 100644
--- a/packages/ckeditor5/src/plugins/link_embed/link_embed_title_form.spec.ts
+++ b/packages/ckeditor5/src/plugins/link_embed/link_embed_title_form.spec.ts
@@ -3,10 +3,11 @@ import { describe, expect, it, vi } from "vitest";
import LinkEmbedTitleFormView from "./link_embed_title_form.js";
-const translate = (_key: string, fallback: string) => fallback;
+// Stands in for `editor.t`: no dictionary, so each message id renders as its own English text.
+const t = (message: string) => message;
function createForm(): LinkEmbedTitleFormView {
- const form = new LinkEmbedTitleFormView(new Locale(), translate);
+ const form = new LinkEmbedTitleFormView(new Locale(), t);
form.render();
return form;
}
diff --git a/packages/ckeditor5/src/plugins/link_embed/link_embed_title_form.ts b/packages/ckeditor5/src/plugins/link_embed/link_embed_title_form.ts
index 21f2b28b9a..5a93a2249f 100644
--- a/packages/ckeditor5/src/plugins/link_embed/link_embed_title_form.ts
+++ b/packages/ckeditor5/src/plugins/link_embed/link_embed_title_form.ts
@@ -13,8 +13,8 @@ import {
type Locale
} from "ckeditor5";
-/** Resolves a translation key, falling back to the given English text. See `translate.ts`. */
-type Translate = (key: string, fallback: string) => string;
+/** The editor's translation function, taking an English message id. */
+type Translate = (message: string) => string;
/**
* The balloon form behind the widget toolbar's "Edit title" button: a single Title field and a
@@ -38,13 +38,13 @@ export default class LinkEmbedTitleFormView extends View {
private readonly _focusables = new ViewCollection<FocusableView>();
private readonly _focusCycler: FocusCycler;
- constructor(locale: Locale, translate: Translate) {
+ constructor(locale: Locale, t: Translate) {
super(locale);
this.set("title", "");
- this.titleInputView = this._createTitleInput(locale, translate);
- this.saveButtonView = this._createSaveButton(locale, translate);
+ this.titleInputView = this._createTitleInput(locale, t);
+ this.saveButtonView = this._createSaveButton(locale, t);
this.setTemplate({
tag: "form",
@@ -56,7 +56,7 @@ export default class LinkEmbedTitleFormView extends View {
{
tag: "div",
attributes: { class: ["ck", "ck-link-embed-form__heading"] },
- children: [{ text: translate("link_embed.edit_title", "Edit title") }]
+ children: [{ text: t("Edit title") }]
},
this.titleInputView,
{
@@ -113,9 +113,9 @@ export default class LinkEmbedTitleFormView extends View {
this._focusCycler.focusFirst();
}
- private _createTitleInput(locale: Locale, translate: Translate) {
+ private _createTitleInput(locale: Locale, t: Translate) {
const titleInput = new LabeledFieldView(locale, createLabeledInputText);
- titleInput.label = translate("link_embed.title_label", "Title");
+ titleInput.label = t("Title");
// Two-way: the field drives `title`, and reset() drives the field.
titleInput.fieldView.bind("value").to(this, "title");
@@ -127,11 +127,11 @@ export default class LinkEmbedTitleFormView extends View {
return titleInput;
}
- private _createSaveButton(locale: Locale, translate: Translate) {
+ private _createSaveButton(locale: Locale, t: Translate) {
const button = new ButtonView(locale);
button.set({
- label: translate("link_embed.save", "Save"),
+ label: t("Save"),
withText: true,
type: "submit",
class: "ck-button-action ck-button-bold"
diff --git a/packages/ckeditor5/src/plugins/link_embed/link_embed_toolbar.spec.ts b/packages/ckeditor5/src/plugins/link_embed/link_embed_toolbar.spec.ts
index 634ad7de6d..530865ae51 100644
--- a/packages/ckeditor5/src/plugins/link_embed/link_embed_toolbar.spec.ts
+++ b/packages/ckeditor5/src/plugins/link_embed/link_embed_toolbar.spec.ts
@@ -407,9 +407,9 @@ describe("LinkEmbedToolbar", () => {
writer.setSelection(embed, "on");
});
const dropdown = editor.ui.componentFactory.create("linkEmbedDisplayDropdown") as unknown as DropdownView;
- // embedType "opengraph" maps to mode "card"
- const cardMode = LINK_DISPLAY_MODES.find(m => m.value === "card");
- expect(dropdown.buttonView.label).toBe(cardMode?.label);
+ // embedType "opengraph" maps to mode "card". No dictionary is configured, so the label
+ // renders its English message id.
+ expect(dropdown.buttonView.label).toBe("Card");
});
// -----------------------------------------------------------------------
@@ -429,19 +429,21 @@ describe("LinkEmbedToolbar", () => {
for (let i = 0; i < LINK_DISPLAY_MODES.length; i++) {
const item = listView.items.get(i);
const button = item.children.get(0);
- expect(button._displayMode).toBe(LINK_DISPLAY_MODES[i].value);
+ expect(button._displayMode).toBe(LINK_DISPLAY_MODES[i]);
}
});
it("each list item has the correct label", () => {
const dropdown = editor.ui.componentFactory.create("linkEmbedDisplayDropdown") as unknown as DropdownView;
const listView = openDropdown(dropdown);
+ const labels = [];
for (let i = 0; i < LINK_DISPLAY_MODES.length; i++) {
- const item = listView.items.get(i);
- const button = item.children.get(0);
- expect(button.label).toBe(LINK_DISPLAY_MODES[i].label);
+ labels.push(listView.items.get(i).children.get(0).label);
}
+
+ // No dictionary is configured, so each label renders its English message id.
+ expect(labels).toEqual([ "Inline", "Card", "Embed", "Plain link" ]);
});
it("list item isOn is true for the matching mode when a card linkEmbed is selected", () => {
diff --git a/packages/ckeditor5/src/plugins/link_embed/link_embed_toolbar.ts b/packages/ckeditor5/src/plugins/link_embed/link_embed_toolbar.ts
index 7a0bf85cd9..99e7b85a49 100644
--- a/packages/ckeditor5/src/plugins/link_embed/link_embed_toolbar.ts
+++ b/packages/ckeditor5/src/plugins/link_embed/link_embed_toolbar.ts
@@ -20,13 +20,13 @@ import {
import LinkEmbed, {
CHANGE_LINK_DISPLAY_COMMAND,
CHANGE_LINK_PREVIEW_TITLE_COMMAND,
+ getLinkDisplayModeLabel,
LINK_DISPLAY_MODES,
REMOVE_LINK_EMBED_COMMAND,
type LinkDisplayMode
} from "./link_embed.js";
import LinkEmbedTitleFormView from "./link_embed_title_form.js";
import { createCopyUrlButton } from "../copy_link_url.js";
-import { translate } from "../translate.js";
export default class LinkEmbedToolbar extends Plugin {
@@ -82,7 +82,7 @@ class LinkEmbedDisplayDropdown extends Plugin {
componentFactory.add("linkEmbedDisplayDropdown", _locale => {
const dropdownView = createDropdown(editor.locale, DropdownButtonView);
- const displayLabel = translate(editor, "link_embed.display", "Display");
+ const displayLabel = editor.t("Display");
dropdownView.buttonView.set({
withText: true,
@@ -98,8 +98,7 @@ class LinkEmbedDisplayDropdown extends Plugin {
dropdownView.buttonView.bind("label").to(command, "value", (value) => {
if (!value) return displayLabel;
- const mode = LINK_DISPLAY_MODES.find(m => m.value === value);
- return mode ? translate(editor, mode.labelKey, mode.label) : value;
+ return getLinkDisplayModeLabel(editor.t, value);
});
dropdownView.on("execute", evt => {
@@ -118,23 +117,23 @@ class LinkEmbedDisplayDropdown extends Plugin {
private _getItemDefinitions(command: Command & { value: LinkDisplayMode | null; embedAvailable: boolean }): Collection<ListDropdownButtonDefinition> {
const items = new Collection<ListDropdownButtonDefinition>();
- for (const modeDef of LINK_DISPLAY_MODES) {
+ for (const mode of LINK_DISPLAY_MODES) {
const definition: ListDropdownButtonDefinition = {
type: "button",
model: new ViewModel({
- _displayMode: modeDef.value,
- label: translate(this.editor, modeDef.labelKey, modeDef.label),
+ _displayMode: mode,
+ label: getLinkDisplayModeLabel(this.editor.t, mode),
role: "menuitemradio",
withText: true
})
};
definition.model.bind("isOn").to(command, "value", value => {
- return value === modeDef.value;
+ return value === mode;
});
// Hide "Embed" when the URL doesn't support it.
- if (modeDef.value === "embed") {
+ if (mode === "embed") {
definition.model.bind("isVisible").to(command, "embedAvailable");
}
@@ -256,7 +255,7 @@ class LinkEmbedEditTitleButton extends Plugin {
const button = new ButtonView(locale);
button.set({
- label: translate(editor, "link_embed.edit_title", "Edit title"),
+ label: editor.t("Edit title"),
icon: IconPencil,
tooltip: true
});
@@ -318,7 +317,7 @@ class LinkEmbedEditTitleButton extends Plugin {
if (this._formView) return this._formView;
const editor = this.editor;
- const form = new LinkEmbedTitleFormView(editor.locale, (key, fallback) => translate(editor, key, fallback));
+ const form = new LinkEmbedTitleFormView(editor.locale, editor.t);
this._formView = form;
form.on("submit", () => {
diff --git a/packages/ckeditor5/src/plugins/link_embed/link_embed_ui.ts b/packages/ckeditor5/src/plugins/link_embed/link_embed_ui.ts
index d63b416f36..4bfc700984 100644
--- a/packages/ckeditor5/src/plugins/link_embed/link_embed_ui.ts
+++ b/packages/ckeditor5/src/plugins/link_embed/link_embed_ui.ts
@@ -1,7 +1,6 @@
import { isHttpUrl } from '@triliumnext/commons';
import { ButtonView, clickOutsideHandler, ContextualBalloon, Plugin, type Editor, type Observable } from 'ckeditor5';
import linkPreviewIcon from '../../icons/link-preview.svg?raw';
-import { translate } from '../translate.js';
import { LINK_EMBED_COMMAND } from './link_embed_commands.js';
import LinkEmbedFormView from './link_embed_form.js';
@@ -89,7 +88,7 @@ export default class LinkEmbedUI extends Plugin {
if (this._formView) return this._formView;
const editor = this.editor;
- const form = new LinkEmbedFormView(editor.locale, (key, fallback) => translate(editor, key, fallback));
+ const form = new LinkEmbedFormView(editor.locale, editor.t);
this._formView = form;
// The mode selector only offers "Embed" for a URL that has a player behind it — the same
diff --git a/packages/ckeditor5/src/plugins/translate.ts b/packages/ckeditor5/src/plugins/translate.ts
deleted file mode 100644
index de9f990a8a..0000000000
--- a/packages/ckeditor5/src/plugins/translate.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import type { Editor } from "ckeditor5";
-
-/**
- * Resolves a Trilium translation key through the host-provided `translate` bridge (the client sets
- * it in `buildConfig`). Falls back to the English text when no bridge is configured — a standalone
- * editor, or a test — so a plugin never renders a raw translation key at the user.
- */
-export function translate(editor: Editor, key: string, fallback: string): string {
- const translateFn = editor.config.get("translate") as ((key: string) => string) | undefined;
- return translateFn ? translateFn(key) : fallback;
-}