From 795bab9f461320aa2e677280287cf0ef5482153e Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Mon, 25 May 2026 02:50:34 -0400 Subject: [PATCH 1/2] Produce message if locale isn't set when using direct access to MathJax modules. --- ts/core/MathDocument.ts | 5 +++++ ts/util/Locale.ts | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/ts/core/MathDocument.ts b/ts/core/MathDocument.ts index aa250aed7..d8f48781d 100644 --- a/ts/core/MathDocument.ts +++ b/ts/core/MathDocument.ts @@ -37,6 +37,7 @@ import { DOMAdaptor } from '../core/DOMAdaptor.js'; import { BitField, BitFieldClass } from '../util/BitField.js'; import { PrioritizedList } from '../util/PrioritizedList.js'; import { handleRetriesFor } from '../util/Retries.js'; +import { Locale } from '../util/Locale.js'; /*****************************************************************/ @@ -771,6 +772,10 @@ export abstract class AbstractMathDocument implements MathDocument< * @class */ constructor(document: D, adaptor: DOMAdaptor, options: OptionList) { + if (!Locale.initialized) { + // FIXME: add URL when we have one. + console.error('MathJax locales not loaded. You may receive cryptic error messages.'); + } const CLASS = this.constructor as typeof AbstractMathDocument; this.document = document; this.options = userOptions(defaultOptions({}, CLASS.OPTIONS), options); diff --git a/ts/util/Locale.ts b/ts/util/Locale.ts index e7b5ade36..ae1628717 100644 --- a/ts/util/Locale.ts +++ b/ts/util/Locale.ts @@ -35,6 +35,10 @@ export type namedData = { [name: string | number]: string }; * The Locale class for handling localized messages */ export class Locale { + /** + * Whether setLocale() has been called or not. + */ + public static initialized = false; /** * The current locale */ @@ -251,6 +255,7 @@ export class Locale { public static async setLocale( locale: string = this.current ): Promise { + this.initialized = true; this.current = locale; const promises = []; for (const [component, [directory, loaded]] of Object.entries( From 4902c2599e741f91780b0106e9026421683a7984 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Mon, 25 May 2026 19:22:22 -0400 Subject: [PATCH 2/2] Fix format for prettier --- ts/core/MathDocument.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ts/core/MathDocument.ts b/ts/core/MathDocument.ts index d8f48781d..60d722759 100644 --- a/ts/core/MathDocument.ts +++ b/ts/core/MathDocument.ts @@ -774,7 +774,9 @@ export abstract class AbstractMathDocument implements MathDocument< constructor(document: D, adaptor: DOMAdaptor, options: OptionList) { if (!Locale.initialized) { // FIXME: add URL when we have one. - console.error('MathJax locales not loaded. You may receive cryptic error messages.'); + console.error( + 'MathJax locales not loaded. You may receive cryptic error messages.' + ); } const CLASS = this.constructor as typeof AbstractMathDocument; this.document = document;