diff --git a/ts/core/MathDocument.ts b/ts/core/MathDocument.ts index aa250aed7..60d722759 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,12 @@ 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(