Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ts/core/MathDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/*****************************************************************/

Expand Down Expand Up @@ -771,6 +772,12 @@ export abstract class AbstractMathDocument<N, T, D> implements MathDocument<
* @class
*/
constructor(document: D, adaptor: DOMAdaptor<N, T, D>, 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);
Expand Down
5 changes: 5 additions & 0 deletions ts/util/Locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -251,6 +255,7 @@ export class Locale {
public static async setLocale(
locale: string = this.current
): Promise<void[]> {
this.initialized = true;
this.current = locale;
const promises = [];
for (const [component, [directory, loaded]] of Object.entries(
Expand Down