Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(ckeditor5): localize the math strings through editor.t()
Elian Doran06293497cd71
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 5cff178d4d..f2363e19d6 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -3610,15 +3610,21 @@"copy-formatting": "Copy formatting","cut-paste-selection-to-sub-note": "Cut & paste selection to sub-note","date-time": "Date time",+ "display-mode": "Display mode",+ "equation-preview": "Equation preview",+ "error-rendering-equation": "Error rendering equation","footnote": "Footnote","footnote-widget": "footnote widget","important": "Important","include-note": "Include note","insert-footnote-0": "Insert footnote %0",+ "insert-math": "Insert math","internal-trilium-link": "Internal Trilium link","keyboard-shortcut": "Keyboard shortcut",+ "latex": "LaTeX","link-preview": "Link preview","markdown-import-from-clipboard": "Markdown import from clipboard",+ "math-editor-unavailable": "Math editor unavailable","new-footnote": "New footnote","note": "Note","tip": "Tip",diff --git a/packages/ckeditor5/src/plugins/math/math_input_view.ts b/packages/ckeditor5/src/plugins/math/math_input_view.tsindex a2553d3b9c..f99554bc58 100644--- a/packages/ckeditor5/src/plugins/math/math_input_view.ts+++ b/packages/ckeditor5/src/plugins/math/math_input_view.ts@@ -57,8 +57,12 @@ export default class MathInputView extends View {private _updating = false;private static _configured = false;+ /** Replaces the editor when MathLive fails to load; resolved up front, while the locale is at hand. */+ private readonly _unavailableLabel: string;+constructor( locale: Locale ) {super( locale );+ this._unavailableLabel = locale.t( 'Math editor unavailable' );this.latexTextAreaView = new LatexTextAreaView( locale );this.mathFieldFocusableView = new MathFieldFocusableView( locale, this );this.set( 'value', null );@@ -170,7 +174,7 @@ export default class MathInputView extends View {} catch {const c = this.element?.querySelector( '.ck-mathlive-container' );if ( c ) {- c.textContent = 'Math editor unavailable';+ c.textContent = this._unavailableLabel;}}/* v8 ignore stop */diff --git a/packages/ckeditor5/src/plugins/math/math_view.ts b/packages/ckeditor5/src/plugins/math/math_view.tsindex ee2ac02f1f..1163683a66 100644--- a/packages/ckeditor5/src/plugins/math/math_view.ts+++ b/packages/ckeditor5/src/plugins/math/math_view.ts@@ -31,9 +31,13 @@ export default class MathView extends View {*/private options: MathViewOptions;+ /** Shown in place of the equation when rendering fails; resolved up front, while the locale is at hand. */+ private readonly renderErrorLabel: string;+constructor( locale: Locale, options: MathViewOptions ) {super( locale );this.options = options;+ this.renderErrorLabel = locale.t( 'Error rendering equation' );this.set( 'value', '' );this.set( 'display', false );@@ -86,7 +90,7 @@ export default class MathView extends View {/* v8 ignore next -- defensive: updateMath() returns early when there is no element */if ( this.element ) {- this.element.textContent = 'Error rendering equation';+ this.element.textContent = this.renderErrorLabel;this.element.classList.add( 'ck-math-render-error' );}} );