diff --git a/components/mjs/a11y/explorer/en.js b/components/mjs/a11y/explorer/en.js deleted file mode 100644 index 80967cfb3..000000000 --- a/components/mjs/a11y/explorer/en.js +++ /dev/null @@ -1,5 +0,0 @@ -import { Locale } from '#js/util/Locale.js'; -import { COMPONENT } from '#js/a11y/explorer/__locales__/Component.js'; -import data from '#ts/a11y/explorer/__locales__/en.json' with {type: 'json'}; - -Locale.registerMessages(COMPONENT, 'en', data); diff --git a/components/mjs/a11y/explorer/explorer.js b/components/mjs/a11y/explorer/explorer.js index 5f8c7463f..4c3a9c89e 100644 --- a/components/mjs/a11y/explorer/explorer.js +++ b/components/mjs/a11y/explorer/explorer.js @@ -1,5 +1,4 @@ import './lib/explorer.js'; -import './en.js'; import {ExplorerHandler} from '#js/a11y/explorer.js'; import {hasWindow} from '#js/util/context.js'; diff --git a/components/mjs/a11y/semantic-enrich/en.js b/components/mjs/a11y/semantic-enrich/en.js deleted file mode 100644 index b6f8eb150..000000000 --- a/components/mjs/a11y/semantic-enrich/en.js +++ /dev/null @@ -1,5 +0,0 @@ -import { Locale } from '#js/util/Locale.js'; -import { COMPONENT } from '#js/a11y/semantic-enrich/__locales__/Component.js'; -import data from '#ts/a11y/semantic-enrich/__locales__/en.json' with {type: 'json'}; - -Locale.registerMessages(COMPONENT, 'en', data); diff --git a/components/mjs/a11y/semantic-enrich/semantic-enrich.js b/components/mjs/a11y/semantic-enrich/semantic-enrich.js index 3a5dabaca..9b15f1837 100644 --- a/components/mjs/a11y/semantic-enrich/semantic-enrich.js +++ b/components/mjs/a11y/semantic-enrich/semantic-enrich.js @@ -1,5 +1,4 @@ import './lib/semantic-enrich.js'; -import './en.js'; import {combineDefaults} from '#js/components/global.js'; import {EnrichHandler} from '#js/a11y/semantic-enrich.js'; diff --git a/components/mjs/a11y/speech/en.js b/components/mjs/a11y/speech/en.js deleted file mode 100644 index c90b82e93..000000000 --- a/components/mjs/a11y/speech/en.js +++ /dev/null @@ -1,5 +0,0 @@ -import { Locale } from '#js/util/Locale.js'; -import { COMPONENT } from '#js/a11y/speech/__locales__/Component.js'; -import data from '#ts/a11y/speech/__locales__/en.json' with {type: 'json'}; - -Locale.registerMessages(COMPONENT, 'en', data); diff --git a/components/mjs/a11y/speech/speech.js b/components/mjs/a11y/speech/speech.js index aea74a3ec..4f6aae494 100644 --- a/components/mjs/a11y/speech/speech.js +++ b/components/mjs/a11y/speech/speech.js @@ -1,5 +1,4 @@ import './lib/speech.js'; -import './en.js'; import {combineDefaults} from '#js/components/global.js'; import {Package} from '#js/components/package.js'; diff --git a/components/mjs/adaptors/linkedom/en.js b/components/mjs/adaptors/linkedom/en.js deleted file mode 100644 index aba6031c5..000000000 --- a/components/mjs/adaptors/linkedom/en.js +++ /dev/null @@ -1,5 +0,0 @@ -import { Locale } from '#js/util/Locale.js'; -import { COMPONENT } from '#js/adaptors/linkedom/__locales__/Component.js'; -import data from '#ts/adaptors/linkedom/__locales__/en.json' with {type: 'json'}; - -Locale.registerMessages(COMPONENT, 'en', data); diff --git a/components/mjs/adaptors/linkedom/linkedom.js b/components/mjs/adaptors/linkedom/linkedom.js index c39494d85..8f4961c0c 100644 --- a/components/mjs/adaptors/linkedom/linkedom.js +++ b/components/mjs/adaptors/linkedom/linkedom.js @@ -1,5 +1,4 @@ import './lib/linkedom.js'; -import './en.js'; import {linkedomAdaptor} from '#js/adaptors/linkedomAdaptor.js'; diff --git a/components/mjs/core/core.js b/components/mjs/core/core.js index 7e39c9f68..d583d9355 100644 --- a/components/mjs/core/core.js +++ b/components/mjs/core/core.js @@ -5,8 +5,6 @@ import {HTMLHandler} from '#js/handlers/html/HTMLHandler.js'; import {browserAdaptor} from '#js/adaptors/browserAdaptor.js'; import {Package} from '#js/components/package.js'; -import './en.js'; - if (MathJax.startup) { MathJax.startup.registerConstructor('HTMLHandler', HTMLHandler); MathJax.startup.registerConstructor('browserAdaptor', browserAdaptor); diff --git a/components/mjs/core/en.js b/components/mjs/core/en.js deleted file mode 100644 index ed327a98e..000000000 --- a/components/mjs/core/en.js +++ /dev/null @@ -1,5 +0,0 @@ -import { Locale } from '#js/util/Locale.js'; -import { COMPONENT } from '#js/core/__locales__/Component.js'; -import data from '#ts/core/__locales__/en.json' with {type: 'json'}; - -Locale.registerMessages(COMPONENT, 'en', data); diff --git a/components/mjs/input/mml/en.js b/components/mjs/input/mml/en.js deleted file mode 100644 index 879a97177..000000000 --- a/components/mjs/input/mml/en.js +++ /dev/null @@ -1,5 +0,0 @@ -import { Locale } from '#js/util/Locale.js'; -import { COMPONENT } from '#js/input/mathml/__locales__/Component.js'; -import data from '#ts/input/mathml/__locales__/en.json' with {type: 'json'}; - -Locale.registerMessages(COMPONENT, 'en', data); diff --git a/components/mjs/input/mml/init.js b/components/mjs/input/mml/init.js index 1ed295e41..aa2291678 100644 --- a/components/mjs/input/mml/init.js +++ b/components/mjs/input/mml/init.js @@ -1,5 +1,4 @@ import './lib/mml.js'; -import './en.js'; import {MathML} from '#js/input/mathml.js'; export {MathML}; diff --git a/components/mjs/input/tex/en.js b/components/mjs/input/tex/en.js deleted file mode 100644 index e5d0390b9..000000000 --- a/components/mjs/input/tex/en.js +++ /dev/null @@ -1,8 +0,0 @@ -import { Locale } from '#js/util/Locale.js'; -import { COMPONENT } from '#js/input/tex/__locales__/Component.js'; -import { COMPONENT as BASE } from '#js/input/tex/base/__locales__/Component.js'; -import data from '#ts/input/tex/__locales__/en.json' with {type: 'json'}; -import basedata from '#ts/input/tex/base/__locales__/en.json' with {type: 'json'}; - -Locale.registerMessages(COMPONENT, 'en', data); -Locale.registerMessages(BASE, 'en', basedata); diff --git a/components/mjs/input/tex/extensions/ams/ams.js b/components/mjs/input/tex/extensions/ams/ams.js index 758b79ab1..d5ea9f287 100644 --- a/components/mjs/input/tex/extensions/ams/ams.js +++ b/components/mjs/input/tex/extensions/ams/ams.js @@ -1,2 +1 @@ import './lib/ams.js'; -import './en.js'; diff --git a/components/mjs/input/tex/extensions/ams/en.js b/components/mjs/input/tex/extensions/ams/en.js deleted file mode 100644 index ea84a3719..000000000 --- a/components/mjs/input/tex/extensions/ams/en.js +++ /dev/null @@ -1,5 +0,0 @@ -import { Locale } from '#js/util/Locale.js'; -import { COMPONENT } from '#js/input/tex/ams/__locales__/Component.js'; -import data from '#ts/input/tex/ams/__locales__/en.json' with {type: 'json'}; - -Locale.registerMessages(COMPONENT, 'en', data); diff --git a/components/mjs/input/tex/extensions/bbox/bbox.js b/components/mjs/input/tex/extensions/bbox/bbox.js index 66f9a0896..16c7d93b5 100644 --- a/components/mjs/input/tex/extensions/bbox/bbox.js +++ b/components/mjs/input/tex/extensions/bbox/bbox.js @@ -1,2 +1 @@ import './lib/bbox.js'; -import './en.js'; diff --git a/components/mjs/input/tex/extensions/bbox/en.js b/components/mjs/input/tex/extensions/bbox/en.js deleted file mode 100644 index 490f64ff3..000000000 --- a/components/mjs/input/tex/extensions/bbox/en.js +++ /dev/null @@ -1,5 +0,0 @@ -import { Locale } from '#js/util/Locale.js'; -import { COMPONENT } from '#js/input/tex/bbox/__locales__/Component.js'; -import data from '#ts/input/tex/bbox/__locales__/en.json' with {type: 'json'}; - -Locale.registerMessages(COMPONENT, 'en', data); diff --git a/components/mjs/input/tex/extensions/begingroup/begingroup.js b/components/mjs/input/tex/extensions/begingroup/begingroup.js index d1a8a5ff3..698d543f6 100644 --- a/components/mjs/input/tex/extensions/begingroup/begingroup.js +++ b/components/mjs/input/tex/extensions/begingroup/begingroup.js @@ -1,2 +1 @@ import './lib/begingroup.js'; -import './en.js'; diff --git a/components/mjs/input/tex/extensions/begingroup/en.js b/components/mjs/input/tex/extensions/begingroup/en.js deleted file mode 100644 index 8fe5c7caf..000000000 --- a/components/mjs/input/tex/extensions/begingroup/en.js +++ /dev/null @@ -1,5 +0,0 @@ -import { Locale } from '#js/util/Locale.js'; -import { COMPONENT } from '#js/input/tex/begingroup/__locales__/Component.js'; -import data from '#ts/input/tex/begingroup/__locales__/en.json' with {type: 'json'}; - -Locale.registerMessages(COMPONENT, 'en', data); diff --git a/components/mjs/input/tex/extensions/bussproofs/bussproofs.js b/components/mjs/input/tex/extensions/bussproofs/bussproofs.js index 72fe949c5..07bcb3652 100644 --- a/components/mjs/input/tex/extensions/bussproofs/bussproofs.js +++ b/components/mjs/input/tex/extensions/bussproofs/bussproofs.js @@ -1,2 +1 @@ import './lib/bussproofs.js'; -import './en.js'; diff --git a/components/mjs/input/tex/extensions/bussproofs/en.js b/components/mjs/input/tex/extensions/bussproofs/en.js deleted file mode 100644 index 06fc4a971..000000000 --- a/components/mjs/input/tex/extensions/bussproofs/en.js +++ /dev/null @@ -1,5 +0,0 @@ -import { Locale } from '#js/util/Locale.js'; -import { COMPONENT } from '#js/input/tex/bussproofs/__locales__/Component.js'; -import data from '#ts/input/tex/bussproofs/__locales__/en.json' with {type: 'json'}; - -Locale.registerMessages(COMPONENT, 'en', data); diff --git a/components/mjs/input/tex/extensions/cases/cases.js b/components/mjs/input/tex/extensions/cases/cases.js index 01d218705..9102348a7 100644 --- a/components/mjs/input/tex/extensions/cases/cases.js +++ b/components/mjs/input/tex/extensions/cases/cases.js @@ -1,2 +1 @@ import './lib/cases.js'; -import './en.js'; diff --git a/components/mjs/input/tex/extensions/cases/en.js b/components/mjs/input/tex/extensions/cases/en.js deleted file mode 100644 index aa24bf4ae..000000000 --- a/components/mjs/input/tex/extensions/cases/en.js +++ /dev/null @@ -1,5 +0,0 @@ -import { Locale } from '#js/util/Locale.js'; -import { COMPONENT } from '#js/input/tex/cases/__locales__/Component.js'; -import data from '#ts/input/tex/cases/__locales__/en.json' with {type: 'json'}; - -Locale.registerMessages(COMPONENT, 'en', data); diff --git a/components/mjs/input/tex/extensions/color/color.js b/components/mjs/input/tex/extensions/color/color.js index 033e0f119..4a4214c62 100644 --- a/components/mjs/input/tex/extensions/color/color.js +++ b/components/mjs/input/tex/extensions/color/color.js @@ -1,2 +1 @@ import './lib/color.js'; -import './en.js'; diff --git a/components/mjs/input/tex/extensions/color/en.js b/components/mjs/input/tex/extensions/color/en.js deleted file mode 100644 index 91dc61312..000000000 --- a/components/mjs/input/tex/extensions/color/en.js +++ /dev/null @@ -1,5 +0,0 @@ -import { Locale } from '#js/util/Locale.js'; -import { COMPONENT } from '#js/input/tex/color/__locales__/Component.js'; -import data from '#ts/input/tex/color/__locales__/en.json' with {type: 'json'}; - -Locale.registerMessages(COMPONENT, 'en', data); diff --git a/components/mjs/input/tex/extensions/colortbl/colortbl.js b/components/mjs/input/tex/extensions/colortbl/colortbl.js index 4cd8d16fb..fbdf6e67f 100644 --- a/components/mjs/input/tex/extensions/colortbl/colortbl.js +++ b/components/mjs/input/tex/extensions/colortbl/colortbl.js @@ -1,2 +1 @@ import './lib/colortbl.js'; -import './en.js'; diff --git a/components/mjs/input/tex/extensions/colortbl/en.js b/components/mjs/input/tex/extensions/colortbl/en.js deleted file mode 100644 index 2547e29b7..000000000 --- a/components/mjs/input/tex/extensions/colortbl/en.js +++ /dev/null @@ -1,5 +0,0 @@ -import { Locale } from '#js/util/Locale.js'; -import { COMPONENT } from '#js/input/tex/colortbl/__locales__/Component.js'; -import data from '#ts/input/tex/colortbl/__locales__/en.json' with {type: 'json'}; - -Locale.registerMessages(COMPONENT, 'en', data); diff --git a/components/mjs/input/tex/extensions/empheq/empheq.js b/components/mjs/input/tex/extensions/empheq/empheq.js index c5edee018..35d50ed09 100644 --- a/components/mjs/input/tex/extensions/empheq/empheq.js +++ b/components/mjs/input/tex/extensions/empheq/empheq.js @@ -1,2 +1 @@ import './lib/empheq.js'; -import './en.js'; diff --git a/components/mjs/input/tex/extensions/empheq/en.js b/components/mjs/input/tex/extensions/empheq/en.js deleted file mode 100644 index 970d89f56..000000000 --- a/components/mjs/input/tex/extensions/empheq/en.js +++ /dev/null @@ -1,5 +0,0 @@ -import { Locale } from '#js/util/Locale.js'; -import { COMPONENT } from '#js/input/tex/empheq/__locales__/Component.js'; -import data from '#ts/input/tex/empheq/__locales__/en.json' with {type: 'json'}; - -Locale.registerMessages(COMPONENT, 'en', data); diff --git a/components/mjs/input/tex/extensions/extpfeil/en.js b/components/mjs/input/tex/extensions/extpfeil/en.js deleted file mode 100644 index 4fb461ecc..000000000 --- a/components/mjs/input/tex/extensions/extpfeil/en.js +++ /dev/null @@ -1,5 +0,0 @@ -import { Locale } from '#js/util/Locale.js'; -import { COMPONENT } from '#js/input/tex/extpfeil/__locales__/Component.js'; -import data from '#ts/input/tex/extpfeil/__locales__/en.json' with {type: 'json'}; - -Locale.registerMessages(COMPONENT, 'en', data); diff --git a/components/mjs/input/tex/extensions/extpfeil/extpfeil.js b/components/mjs/input/tex/extensions/extpfeil/extpfeil.js index 182ea1b80..ad54bb1c9 100644 --- a/components/mjs/input/tex/extensions/extpfeil/extpfeil.js +++ b/components/mjs/input/tex/extensions/extpfeil/extpfeil.js @@ -1,2 +1 @@ import './lib/extpfeil.js'; -import './en.js'; diff --git a/components/mjs/input/tex/extensions/html/en.js b/components/mjs/input/tex/extensions/html/en.js deleted file mode 100644 index a771df845..000000000 --- a/components/mjs/input/tex/extensions/html/en.js +++ /dev/null @@ -1,5 +0,0 @@ -import { Locale } from '#js/util/Locale.js'; -import { COMPONENT } from '#js/input/tex/html/__locales__/Component.js'; -import data from '#ts/input/tex/html/__locales__/en.json' with {type: 'json'}; - -Locale.registerMessages(COMPONENT, 'en', data); diff --git a/components/mjs/input/tex/extensions/html/html.js b/components/mjs/input/tex/extensions/html/html.js index 2503332d9..9c3a20950 100644 --- a/components/mjs/input/tex/extensions/html/html.js +++ b/components/mjs/input/tex/extensions/html/html.js @@ -1,2 +1 @@ import './lib/html.js'; -import './en.js'; diff --git a/components/mjs/input/tex/extensions/mathtools/en.js b/components/mjs/input/tex/extensions/mathtools/en.js deleted file mode 100644 index 0425d90d8..000000000 --- a/components/mjs/input/tex/extensions/mathtools/en.js +++ /dev/null @@ -1,5 +0,0 @@ -import { Locale } from '#js/util/Locale.js'; -import { COMPONENT } from '#js/input/tex/mathtools/__locales__/Component.js'; -import data from '#ts/input/tex/mathtools/__locales__/en.json' with {type: 'json'}; - -Locale.registerMessages(COMPONENT, 'en', data); diff --git a/components/mjs/input/tex/extensions/mathtools/mathtools.js b/components/mjs/input/tex/extensions/mathtools/mathtools.js index c3ed5c4c0..ec95d66b6 100644 --- a/components/mjs/input/tex/extensions/mathtools/mathtools.js +++ b/components/mjs/input/tex/extensions/mathtools/mathtools.js @@ -1,2 +1 @@ import './lib/mathtools.js'; -import './en.js'; diff --git a/components/mjs/input/tex/extensions/mhchem/en.js b/components/mjs/input/tex/extensions/mhchem/en.js deleted file mode 100644 index 25dae1fd6..000000000 --- a/components/mjs/input/tex/extensions/mhchem/en.js +++ /dev/null @@ -1,5 +0,0 @@ -import { Locale } from '#js/util/Locale.js'; -import { COMPONENT } from '#js/input/tex/mhchem/__locales__/Component.js'; -import data from '#ts/input/tex/mhchem/__locales__/en.json' with {type: 'json'}; - -Locale.registerMessages(COMPONENT, 'en', data); diff --git a/components/mjs/input/tex/extensions/mhchem/mhchem.js b/components/mjs/input/tex/extensions/mhchem/mhchem.js index 815a7b99e..a5d5490e5 100644 --- a/components/mjs/input/tex/extensions/mhchem/mhchem.js +++ b/components/mjs/input/tex/extensions/mhchem/mhchem.js @@ -1,5 +1,4 @@ import './lib/mhchem.js'; -import './en.js'; import {fontExtension} from '../../extension.js'; fontExtension('[tex]/mhchem', 'mathjax-mhchem-font-extension'); diff --git a/components/mjs/input/tex/extensions/newcommand/en.js b/components/mjs/input/tex/extensions/newcommand/en.js deleted file mode 100644 index 2170df7c4..000000000 --- a/components/mjs/input/tex/extensions/newcommand/en.js +++ /dev/null @@ -1,5 +0,0 @@ -import { Locale } from '#js/util/Locale.js'; -import { COMPONENT } from '#js/input/tex/newcommand/__locales__/Component.js'; -import data from '#ts/input/tex/newcommand/__locales__/en.json' with {type: 'json'}; - -Locale.registerMessages(COMPONENT, 'en', data); diff --git a/components/mjs/input/tex/extensions/newcommand/newcommand.js b/components/mjs/input/tex/extensions/newcommand/newcommand.js index d7084b01d..86efc9856 100644 --- a/components/mjs/input/tex/extensions/newcommand/newcommand.js +++ b/components/mjs/input/tex/extensions/newcommand/newcommand.js @@ -1,2 +1 @@ import './lib/newcommand.js'; -import './en.js'; diff --git a/components/mjs/input/tex/extensions/physics/en.js b/components/mjs/input/tex/extensions/physics/en.js deleted file mode 100644 index 214dad467..000000000 --- a/components/mjs/input/tex/extensions/physics/en.js +++ /dev/null @@ -1,5 +0,0 @@ -import { Locale } from '#js/util/Locale.js'; -import { COMPONENT } from '#js/input/tex/physics/__locales__/Component.js'; -import data from '#ts/input/tex/physics/__locales__/en.json' with {type: 'json'}; - -Locale.registerMessages(COMPONENT, 'en', data); diff --git a/components/mjs/input/tex/extensions/physics/physics.js b/components/mjs/input/tex/extensions/physics/physics.js index c3e8fe543..a592a483d 100644 --- a/components/mjs/input/tex/extensions/physics/physics.js +++ b/components/mjs/input/tex/extensions/physics/physics.js @@ -1,2 +1 @@ import './lib/physics.js'; -import './en.js'; diff --git a/components/mjs/input/tex/extensions/require/en.js b/components/mjs/input/tex/extensions/require/en.js deleted file mode 100644 index b75692d89..000000000 --- a/components/mjs/input/tex/extensions/require/en.js +++ /dev/null @@ -1,5 +0,0 @@ -import { Locale } from '#js/util/Locale.js'; -import { COMPONENT } from '#js/input/tex/require/__locales__/Component.js'; -import data from '#ts/input/tex/require/__locales__/en.json' with {type: 'json'}; - -Locale.registerMessages(COMPONENT, 'en', data); diff --git a/components/mjs/input/tex/extensions/require/require.js b/components/mjs/input/tex/extensions/require/require.js index 9f1ac312b..2031b81ba 100644 --- a/components/mjs/input/tex/extensions/require/require.js +++ b/components/mjs/input/tex/extensions/require/require.js @@ -1,2 +1 @@ import './lib/require.js'; -import './en.js'; diff --git a/components/mjs/input/tex/extensions/setoptions/en.js b/components/mjs/input/tex/extensions/setoptions/en.js deleted file mode 100644 index c167cd3e9..000000000 --- a/components/mjs/input/tex/extensions/setoptions/en.js +++ /dev/null @@ -1,5 +0,0 @@ -import { Locale } from '#js/util/Locale.js'; -import { COMPONENT } from '#js/input/tex/setoptions/__locales__/Component.js'; -import data from '#ts/input/tex/setoptions/__locales__/en.json' with {type: 'json'}; - -Locale.registerMessages(COMPONENT, 'en', data); diff --git a/components/mjs/input/tex/extensions/setoptions/setoptions.js b/components/mjs/input/tex/extensions/setoptions/setoptions.js index 5c7726f40..299921694 100644 --- a/components/mjs/input/tex/extensions/setoptions/setoptions.js +++ b/components/mjs/input/tex/extensions/setoptions/setoptions.js @@ -1,2 +1 @@ import './lib/setoptions.js'; -import './en.js'; diff --git a/components/mjs/input/tex/extensions/textmacros/en.js b/components/mjs/input/tex/extensions/textmacros/en.js deleted file mode 100644 index d142b36c3..000000000 --- a/components/mjs/input/tex/extensions/textmacros/en.js +++ /dev/null @@ -1,5 +0,0 @@ -import { Locale } from '#js/util/Locale.js'; -import { COMPONENT } from '#js/input/tex/textmacros/__locales__/Component.js'; -import data from '#ts/input/tex/textmacros/__locales__/en.json' with {type: 'json'}; - -Locale.registerMessages(COMPONENT, 'en', data); diff --git a/components/mjs/input/tex/extensions/textmacros/textmacros.js b/components/mjs/input/tex/extensions/textmacros/textmacros.js index 5b9c54800..ea05a2a68 100644 --- a/components/mjs/input/tex/extensions/textmacros/textmacros.js +++ b/components/mjs/input/tex/extensions/textmacros/textmacros.js @@ -1,2 +1 @@ import './lib/textmacros.js'; -import './en.js'; diff --git a/components/mjs/input/tex/extensions/unicode/en.js b/components/mjs/input/tex/extensions/unicode/en.js deleted file mode 100644 index 45970499d..000000000 --- a/components/mjs/input/tex/extensions/unicode/en.js +++ /dev/null @@ -1,5 +0,0 @@ -import { Locale } from '#js/util/Locale.js'; -import { COMPONENT } from '#js/input/tex/unicode/__locales__/Component.js'; -import data from '#ts/input/tex/unicode/__locales__/en.json' with {type: 'json'}; - -Locale.registerMessages(COMPONENT, 'en', data); diff --git a/components/mjs/input/tex/extensions/unicode/unicode.js b/components/mjs/input/tex/extensions/unicode/unicode.js index 99ff14d1a..63b911046 100644 --- a/components/mjs/input/tex/extensions/unicode/unicode.js +++ b/components/mjs/input/tex/extensions/unicode/unicode.js @@ -1,2 +1 @@ import './lib/unicode.js'; -import './en.js'; diff --git a/components/mjs/input/tex/extensions/verb/en.js b/components/mjs/input/tex/extensions/verb/en.js deleted file mode 100644 index a471b5616..000000000 --- a/components/mjs/input/tex/extensions/verb/en.js +++ /dev/null @@ -1,5 +0,0 @@ -import { Locale } from '#js/util/Locale.js'; -import { COMPONENT } from '#js/input/tex/verb/__locales__/Component.js'; -import data from '#ts/input/tex/verb/__locales__/en.json' with {type: 'json'}; - -Locale.registerMessages(COMPONENT, 'en', data); diff --git a/components/mjs/input/tex/extensions/verb/verb.js b/components/mjs/input/tex/extensions/verb/verb.js index 4380bf010..48b89414b 100644 --- a/components/mjs/input/tex/extensions/verb/verb.js +++ b/components/mjs/input/tex/extensions/verb/verb.js @@ -1,2 +1 @@ import './lib/verb.js'; -import './en.js'; diff --git a/components/mjs/input/tex/tex.js b/components/mjs/input/tex/tex.js index 06226af33..32766c2dc 100644 --- a/components/mjs/input/tex/tex.js +++ b/components/mjs/input/tex/tex.js @@ -1,5 +1,4 @@ import './lib/tex.js'; -import './en.js'; import {registerTeX} from './register.js'; import {Loader} from '#js/components/loader.js'; diff --git a/components/mjs/locale/config.json b/components/mjs/locale/config.json new file mode 100644 index 000000000..1d59aad8c --- /dev/null +++ b/components/mjs/locale/config.json @@ -0,0 +1,7 @@ +{ + "copy": { + "to": "[bundle]/locale", + "from": "[ts]/util/Locale", + "copy": ["__locales__"] + } +} diff --git a/components/mjs/ui/menu/en.js b/components/mjs/ui/menu/en.js deleted file mode 100644 index 22d1549ed..000000000 --- a/components/mjs/ui/menu/en.js +++ /dev/null @@ -1,5 +0,0 @@ -import { Locale } from '#js/util/Locale.js'; -import { COMPONENT } from '#js/ui/menu/__locales__/Component.js'; -import data from '#ts/ui/menu/__locales__/en.json' with {type: 'json'}; - -Locale.registerMessages(COMPONENT, 'en', data); diff --git a/components/mjs/ui/menu/menu.js b/components/mjs/ui/menu/menu.js index 91cd36b90..b4e50d092 100644 --- a/components/mjs/ui/menu/menu.js +++ b/components/mjs/ui/menu/menu.js @@ -1,5 +1,4 @@ import './lib/menu.js'; -import './en.js'; import {combineDefaults} from '#js/components/global.js'; import {MenuHandler} from '#js/ui/menu/MenuHandler.js'; diff --git a/package.json b/package.json index 13b47db99..b000e5df1 100644 --- a/package.json +++ b/package.json @@ -84,12 +84,13 @@ "copy:assets": "pnpm -s log:comp 'Copying assets'; copy() { for name in locales mj2 mml3 html; do pnpm -s copy:$name ${1:-mjs}; done; }; copy", "copy:bundle": "copy() { components/bin/makeAll --copy --terse components/mjs/${1:-}; }; copy", "copy:html": "copy() { pnpm -s log:single 'Copying sre auxiliary files'; pnpm copyfiles -u 1 'ts/a11y/sre/*.html' 'ts/a11y/sre/require.*' $1; }; copy", - "copy:locales": "copy() { for name in core tex mml menu a11y adaptors; do pnpm -s copy:locales:$name ${1:-mjs}; done; }; copy ", + "copy:locales": "copy() { for name in core tex mml menu util a11y adaptors; do pnpm -s copy:locales:$name ${1:-mjs}; done; }; copy ", "copy:locales:a11y": "pnpm -s log:single 'Copying a11y locales'; copy() { pnpm copyfiles -u 1 'ts/a11y/*/__locales__/*.json' $1; }; copy", "copy:locales:adaptors": "pnpm -s log:single 'Copying DOMAdaptor locales'; copy() { pnpm copyfiles -u 1 'ts/adaptors/*/__locales__/*.json' $1; }; copy", "copy:locales:core": "pnpm -s log:single 'Copying core locales'; copy() { pnpm copyfiles -u 1 'ts/core/__locales__/*.json' $1; }; copy", "copy:locales:menu": "pnpm -s log:single 'Copying menu locales'; copy() { pnpm copyfiles -u 1 'ts/ui/menu/__locales__/*.json' $1; }; copy", "copy:locales:mml": "pnpm -s log:single 'Copying MathML locales'; copy() { pnpm copyfiles -u 1 'ts/input/mathml/__locales__/*.json' $1; }; copy", + "copy:locales:util": "pnpm -s log:single 'Copying utility locales'; copy() { pnpm copyfiles -u 1 'ts/util/*/__locales__/*.json' $1; }; copy", "copy:locales:tex": "pnpm -s log:single 'Copying TeX locales'; copy() { pnpm copyfiles -u 1 'ts/input/tex/__locales__/*.json' $1 && pnpm copyfiles -u 3 'ts/input/tex/*/__locales__/*.json' $1/input/tex/extensions; }; copy", "copy:mj2": "copy() { pnpm -s log:single 'Copying legacy code AsciiMath'; pnpm copyfiles -u 1 'ts/input/asciimath/legacy/**/*' $1; }; copy", "copy:mml3": "copy() { pnpm -s log:single 'Copying MathML3 extension json'; pnpm copyfiles -u 1 ts/input/mathml/mml3/mml3.sef.json $1; }; copy", diff --git a/testsuite/tests/util/Locale.test.ts b/testsuite/tests/util/Locale.test.ts index e3a96c09b..b6648fa65 100644 --- a/testsuite/tests/util/Locale.test.ts +++ b/testsuite/tests/util/Locale.test.ts @@ -46,6 +46,7 @@ describe('Locale', () => { expect(Locale.message('component', 'Id1', 'message', 'Locale')).toBe( 'Test of message in Locale' ); + delete locale.locations.component; }); /********************************************************************************/ @@ -85,6 +86,16 @@ describe('Locale', () => { expect(Locale.message('undefined', 'Id1')).toBe(''); Locale.current = 'en'; Locale.default = 'en'; + delete (Locale as any).locations.component; + }); + + + /********************************************************************************/ + + test('Register messages for unknown component', async () => { + expect(trapOutput('warn', () => + Locale.registerMessages('unknown', 'en', {}) + )).toBe(`MathJax(Locale): Component 'unknown' doesn't exist`); }); /********************************************************************************/ @@ -95,6 +106,7 @@ describe('Locale', () => { await Locale.setLocale('test'); expect(Locale.message('component', 'test1')).toBe('Has % percent'); Locale.isComponent = false; + delete (Locale as any).locations.component; }); /********************************************************************************/ @@ -120,6 +132,8 @@ describe('Locale', () => { }); expect(message).toContain("MathJax(fallback): Can't load 'xy.json'"); expect(locale.data.fallback?.en).toEqual({ Id1: 'Test of %1 in %2' }); + delete locale.locations.fallback; + delete locale.data.fallback; }); /********************************************************************************/ @@ -130,6 +144,7 @@ describe('Locale', () => { Locale.warn('component', 'test2', 'warn') ); expect(message).toEqual('Has warn one'); + delete (Locale as any).locations.component; }); /********************************************************************************/ @@ -172,6 +187,8 @@ describe('Locale', () => { // Locale.syncLoad = sync; console.error = error; + delete locale.locations.sync; + delete locale.data.sync; }); /********************************************************************************/ @@ -216,6 +233,8 @@ describe('Locale', () => { // Locale.asyncLoad = async; Locale.syncLoad = sync; + delete (Locale as any).locations.sync; + delete (Locale as any).data.sync; mathjax.asyncLoad = load; mathjax.asyncIsSynchronous = isSync; }); diff --git a/ts/a11y/explorer/__locales__/Component.ts b/ts/a11y/explorer/__locales__/Component.ts index 9df7f4dda..b5e891580 100644 --- a/ts/a11y/explorer/__locales__/Component.ts +++ b/ts/a11y/explorer/__locales__/Component.ts @@ -22,10 +22,12 @@ */ import { Locale, namedData } from '../../../util/Locale.js'; +import data from './en.json' with {type: 'json'}; export const COMPONENT = 'a11y/explorer'; Locale.registerLocaleFiles(COMPONENT, '../ts/a11y/explorer'); +Locale.registerMessages(COMPONENT, 'en', data); /** * Get a localized message for this component diff --git a/ts/a11y/semantic-enrich/__locales__/Component.ts b/ts/a11y/semantic-enrich/__locales__/Component.ts index f96c25b90..e936576c8 100644 --- a/ts/a11y/semantic-enrich/__locales__/Component.ts +++ b/ts/a11y/semantic-enrich/__locales__/Component.ts @@ -22,7 +22,9 @@ */ import { Locale } from '../../../util/Locale.js'; +import data from './en.json' with {type: 'json'}; export const COMPONENT = 'a11y/semantic-enrich'; Locale.registerLocaleFiles(COMPONENT, '../ts/a11y/semantic-enrich'); +Locale.registerMessages(COMPONENT, 'en', data); diff --git a/ts/a11y/speech/__locales__/Component.ts b/ts/a11y/speech/__locales__/Component.ts index 1d319065e..c7274fe18 100644 --- a/ts/a11y/speech/__locales__/Component.ts +++ b/ts/a11y/speech/__locales__/Component.ts @@ -22,10 +22,12 @@ */ import { Locale, namedData } from '../../../util/Locale.js'; +import data from './en.json' with {type: 'json'}; export const COMPONENT = 'a11y/speech'; Locale.registerLocaleFiles(COMPONENT, '../ts/a11y/speech'); +Locale.registerMessages(COMPONENT, 'en', data); /** * Get a localized message for this component diff --git a/ts/adaptors/linkedom/__locales__/Component.ts b/ts/adaptors/linkedom/__locales__/Component.ts index fd2ae87c2..de2ab39f0 100644 --- a/ts/adaptors/linkedom/__locales__/Component.ts +++ b/ts/adaptors/linkedom/__locales__/Component.ts @@ -22,7 +22,9 @@ */ import { Locale } from '../../../util/Locale.js'; +import data from './en.json' with {type: 'json'}; export const COMPONENT = 'adaptors/linkedom'; Locale.registerLocaleFiles(COMPONENT, '../ts/adaptors/linkedom'); +Locale.registerMessages(COMPONENT, 'en', data); diff --git a/ts/core/__locales__/Component.ts b/ts/core/__locales__/Component.ts index 030026917..ba1a23c52 100644 --- a/ts/core/__locales__/Component.ts +++ b/ts/core/__locales__/Component.ts @@ -22,10 +22,12 @@ */ import { Locale, namedData } from '../../util/Locale.js'; +import data from './en.json' with {type: 'json'}; export const COMPONENT = 'core'; Locale.registerLocaleFiles(COMPONENT, '../ts/core'); +Locale.registerMessages(COMPONENT, 'en', data); /** * Get a localized message for this component diff --git a/ts/input/mathml/__locales__/Component.ts b/ts/input/mathml/__locales__/Component.ts index 6363338df..4cf8c44c0 100644 --- a/ts/input/mathml/__locales__/Component.ts +++ b/ts/input/mathml/__locales__/Component.ts @@ -22,10 +22,12 @@ */ import { Locale, namedData } from '../../../util/Locale.js'; +import data from './en.json' with {type: 'json'}; export const COMPONENT = 'input/mml'; Locale.registerLocaleFiles(COMPONENT, '../ts/input/mathml'); +Locale.registerMessages(COMPONENT, 'en', data); /** * Get a localized message for this component diff --git a/ts/input/tex/__locales__/Component.ts b/ts/input/tex/__locales__/Component.ts index 5c31f45db..f198174e4 100644 --- a/ts/input/tex/__locales__/Component.ts +++ b/ts/input/tex/__locales__/Component.ts @@ -22,7 +22,9 @@ */ import { Locale } from '../../../util/Locale.js'; +import data from './en.json' with {type: 'json'}; export const COMPONENT = 'input/tex'; Locale.registerLocaleFiles(COMPONENT, '../ts/input/tex'); +Locale.registerMessages(COMPONENT, 'en', data); diff --git a/ts/input/tex/ams/__locales__/Component.ts b/ts/input/tex/ams/__locales__/Component.ts index b547dcf77..95814b100 100644 --- a/ts/input/tex/ams/__locales__/Component.ts +++ b/ts/input/tex/ams/__locales__/Component.ts @@ -22,7 +22,9 @@ */ import { Locale } from '../../../../util/Locale.js'; +import data from './en.json' with {type: 'json'}; export const COMPONENT = '[tex]/ams'; Locale.registerLocaleFiles(COMPONENT, '../ts/input/tex/ams'); +Locale.registerMessages(COMPONENT, 'en', data); diff --git a/ts/input/tex/bbox/__locales__/Component.ts b/ts/input/tex/bbox/__locales__/Component.ts index 5c1b19e9c..9b7b6d5f0 100644 --- a/ts/input/tex/bbox/__locales__/Component.ts +++ b/ts/input/tex/bbox/__locales__/Component.ts @@ -22,7 +22,9 @@ */ import { Locale } from '../../../../util/Locale.js'; +import data from './en.json' with {type: 'json'}; export const COMPONENT = '[tex]/bbox'; Locale.registerLocaleFiles(COMPONENT, '../ts/input/tex/bbox'); +Locale.registerMessages(COMPONENT, 'en', data); diff --git a/ts/input/tex/begingroup/__locales__/Component.ts b/ts/input/tex/begingroup/__locales__/Component.ts index 0e9b0ae1e..37a9f28b0 100644 --- a/ts/input/tex/begingroup/__locales__/Component.ts +++ b/ts/input/tex/begingroup/__locales__/Component.ts @@ -22,7 +22,9 @@ */ import { Locale } from '../../../../util/Locale.js'; +import data from './en.json' with {type: 'json'}; export const COMPONENT = '[tex]/begingroup'; Locale.registerLocaleFiles(COMPONENT, '../ts/input/tex/begingroup'); +Locale.registerMessages(COMPONENT, 'en', data); diff --git a/ts/input/tex/bussproofs/__locales__/Component.ts b/ts/input/tex/bussproofs/__locales__/Component.ts index 74bcc29ad..c40270d81 100644 --- a/ts/input/tex/bussproofs/__locales__/Component.ts +++ b/ts/input/tex/bussproofs/__locales__/Component.ts @@ -22,7 +22,9 @@ */ import { Locale } from '../../../../util/Locale.js'; +import data from './en.json' with {type: 'json'}; export const COMPONENT = '[tex]/bussproofs'; Locale.registerLocaleFiles(COMPONENT, '../ts/input/tex/bussproofs'); +Locale.registerMessages(COMPONENT, 'en', data); diff --git a/ts/input/tex/bussproofs/__locales__/en.json b/ts/input/tex/bussproofs/__locales__/en.json index 4f38c28d7..c5ba4ceb6 100644 --- a/ts/input/tex/bussproofs/__locales__/en.json +++ b/ts/input/tex/bussproofs/__locales__/en.json @@ -4,5 +4,5 @@ "IllegalProofCommand": "Proof commands only allowed in prooftree environment.", "IllegalUseOfCommand": "Use of %1 does not match its definition.", "MissingProofCommand": "Missing %1 in %2.", - "RequiresOutputJax": "The bussproofs extension requires an output jax with a getBBox() method"; + "RequiresOutputJax": "The bussproofs extension requires an output jax with a getBBox() method" } diff --git a/ts/input/tex/cases/__locales__/Component.ts b/ts/input/tex/cases/__locales__/Component.ts index 6eb0bedce..330291c87 100644 --- a/ts/input/tex/cases/__locales__/Component.ts +++ b/ts/input/tex/cases/__locales__/Component.ts @@ -22,7 +22,9 @@ */ import { Locale } from '../../../../util/Locale.js'; +import data from './en.json' with {type: 'json'}; export const COMPONENT = '[tex]/cases'; Locale.registerLocaleFiles(COMPONENT, '../ts/input/tex/cases'); +Locale.registerMessages(COMPONENT, 'en', data); diff --git a/ts/input/tex/color/__locales__/Component.ts b/ts/input/tex/color/__locales__/Component.ts index d79509c61..af8491aba 100644 --- a/ts/input/tex/color/__locales__/Component.ts +++ b/ts/input/tex/color/__locales__/Component.ts @@ -22,7 +22,9 @@ */ import { Locale } from '../../../../util/Locale.js'; +import data from './en.json' with {type: 'json'}; export const COMPONENT = '[tex]/color'; Locale.registerLocaleFiles(COMPONENT, '../ts/input/tex/color'); +Locale.registerMessages(COMPONENT, 'en', data); diff --git a/ts/input/tex/colortbl/__locales__/Component.ts b/ts/input/tex/colortbl/__locales__/Component.ts index 2415e5895..15353de95 100644 --- a/ts/input/tex/colortbl/__locales__/Component.ts +++ b/ts/input/tex/colortbl/__locales__/Component.ts @@ -22,7 +22,9 @@ */ import { Locale } from '../../../../util/Locale.js'; +import data from './en.json' with {type: 'json'}; export const COMPONENT = '[tex]/colortbl'; Locale.registerLocaleFiles(COMPONENT, '../ts/input/tex/colortbl'); +Locale.registerMessages(COMPONENT, 'en', data); diff --git a/ts/input/tex/empheq/__locales__/Component.ts b/ts/input/tex/empheq/__locales__/Component.ts index a85fd89c3..7cfb2194a 100644 --- a/ts/input/tex/empheq/__locales__/Component.ts +++ b/ts/input/tex/empheq/__locales__/Component.ts @@ -22,7 +22,9 @@ */ import { Locale } from '../../../../util/Locale.js'; +import data from './en.json' with {type: 'json'}; export const COMPONENT = '[tex]/empheq'; Locale.registerLocaleFiles(COMPONENT, '../ts/input/tex/empheq'); +Locale.registerMessages(COMPONENT, 'en', data); diff --git a/ts/input/tex/extpfeil/__locales__/Component.ts b/ts/input/tex/extpfeil/__locales__/Component.ts index cb8ff0e6c..1e7aff5b8 100644 --- a/ts/input/tex/extpfeil/__locales__/Component.ts +++ b/ts/input/tex/extpfeil/__locales__/Component.ts @@ -22,7 +22,9 @@ */ import { Locale } from '../../../../util/Locale.js'; +import data from './en.json' with {type: 'json'}; export const COMPONENT = '[tex]/extpfeil'; Locale.registerLocaleFiles(COMPONENT, '../ts/input/tex/extpfeil'); +Locale.registerMessages(COMPONENT, 'en', data); diff --git a/ts/input/tex/html/__locales__/Component.ts b/ts/input/tex/html/__locales__/Component.ts index fc3eafa07..ec617c693 100644 --- a/ts/input/tex/html/__locales__/Component.ts +++ b/ts/input/tex/html/__locales__/Component.ts @@ -22,7 +22,9 @@ */ import { Locale } from '../../../../util/Locale.js'; +import data from './en.json' with {type: 'json'}; export const COMPONENT = '[tex]/html'; Locale.registerLocaleFiles(COMPONENT, '../ts/input/tex/html'); +Locale.registerMessages(COMPONENT, 'en', data); diff --git a/ts/input/tex/mathtools/__locales__/Component.ts b/ts/input/tex/mathtools/__locales__/Component.ts index 071d87daf..e927c02af 100644 --- a/ts/input/tex/mathtools/__locales__/Component.ts +++ b/ts/input/tex/mathtools/__locales__/Component.ts @@ -22,7 +22,9 @@ */ import { Locale } from '../../../../util/Locale.js'; +import data from './en.json' with {type: 'json'}; export const COMPONENT = '[tex]/mathtools'; Locale.registerLocaleFiles(COMPONENT, '../ts/input/tex/mathtools'); +Locale.registerMessages(COMPONENT, 'en', data); diff --git a/ts/input/tex/mhchem/__locales__/Component.ts b/ts/input/tex/mhchem/__locales__/Component.ts index 66593a0d3..1033ec343 100644 --- a/ts/input/tex/mhchem/__locales__/Component.ts +++ b/ts/input/tex/mhchem/__locales__/Component.ts @@ -22,7 +22,9 @@ */ import { Locale } from '../../../../util/Locale.js'; +import data from './en.json' with {type: 'json'}; export const COMPONENT = '[tex]/mhchem'; Locale.registerLocaleFiles(COMPONENT, '../ts/input/tex/mhchem'); +Locale.registerMessages(COMPONENT, 'en', data); diff --git a/ts/input/tex/newcommand/__locales__/Component.ts b/ts/input/tex/newcommand/__locales__/Component.ts index a7ad030e9..2585989b4 100644 --- a/ts/input/tex/newcommand/__locales__/Component.ts +++ b/ts/input/tex/newcommand/__locales__/Component.ts @@ -22,7 +22,9 @@ */ import { Locale } from '../../../../util/Locale.js'; +import data from './en.json' with {type: 'json'}; export const COMPONENT = '[tex]/newcommand'; Locale.registerLocaleFiles(COMPONENT, '../ts/input/tex/newcommand'); +Locale.registerMessages(COMPONENT, 'en', data); diff --git a/ts/input/tex/physics/__locales__/Component.ts b/ts/input/tex/physics/__locales__/Component.ts index c5c391e2f..c17551445 100644 --- a/ts/input/tex/physics/__locales__/Component.ts +++ b/ts/input/tex/physics/__locales__/Component.ts @@ -22,7 +22,9 @@ */ import { Locale } from '../../../../util/Locale.js'; +import data from './en.json' with {type: 'json'}; export const COMPONENT = '[tex]/physics'; Locale.registerLocaleFiles(COMPONENT, '../ts/input/tex/physics'); +Locale.registerMessages(COMPONENT, 'en', data); diff --git a/ts/input/tex/require/__locales__/Component.ts b/ts/input/tex/require/__locales__/Component.ts index 5519890a3..932d76bb3 100644 --- a/ts/input/tex/require/__locales__/Component.ts +++ b/ts/input/tex/require/__locales__/Component.ts @@ -22,7 +22,9 @@ */ import { Locale } from '../../../../util/Locale.js'; +import data from './en.json' with {type: 'json'}; export const COMPONENT = '[tex]/require'; Locale.registerLocaleFiles(COMPONENT, '../ts/input/tex/require'); +Locale.registerMessages(COMPONENT, 'en', data); diff --git a/ts/input/tex/setoptions/__locales__/Component.ts b/ts/input/tex/setoptions/__locales__/Component.ts index 35630731c..ea0336536 100644 --- a/ts/input/tex/setoptions/__locales__/Component.ts +++ b/ts/input/tex/setoptions/__locales__/Component.ts @@ -22,7 +22,9 @@ */ import { Locale } from '../../../../util/Locale.js'; +import data from './en.json' with {type: 'json'}; export const COMPONENT = '[tex]/setoptions'; Locale.registerLocaleFiles(COMPONENT, '../ts/input/tex/setoptions'); +Locale.registerMessages(COMPONENT, 'en', data); diff --git a/ts/input/tex/textmacros/__locales__/Component.ts b/ts/input/tex/textmacros/__locales__/Component.ts index cfce9e2b0..96855d2ae 100644 --- a/ts/input/tex/textmacros/__locales__/Component.ts +++ b/ts/input/tex/textmacros/__locales__/Component.ts @@ -22,7 +22,9 @@ */ import { Locale } from '../../../../util/Locale.js'; +import data from './en.json' with {type: 'json'}; export const COMPONENT = '[tex]/textmacros'; Locale.registerLocaleFiles(COMPONENT, '../ts/input/tex/textmacros'); +Locale.registerMessages(COMPONENT, 'en', data); diff --git a/ts/input/tex/unicode/__locales__/Component.ts b/ts/input/tex/unicode/__locales__/Component.ts index 776f460d1..dbd33f431 100644 --- a/ts/input/tex/unicode/__locales__/Component.ts +++ b/ts/input/tex/unicode/__locales__/Component.ts @@ -22,7 +22,9 @@ */ import { Locale } from '../../../../util/Locale.js'; +import data from './en.json' with {type: 'json'}; export const COMPONENT = '[tex]/unicode'; Locale.registerLocaleFiles(COMPONENT, '../ts/input/tex/unicode'); +Locale.registerMessages(COMPONENT, 'en', data); diff --git a/ts/input/tex/verb/__locales__/Component.ts b/ts/input/tex/verb/__locales__/Component.ts index 5b85bb7fe..314c7a569 100644 --- a/ts/input/tex/verb/__locales__/Component.ts +++ b/ts/input/tex/verb/__locales__/Component.ts @@ -22,7 +22,9 @@ */ import { Locale } from '../../../../util/Locale.js'; +import data from './en.json' with {type: 'json'}; export const COMPONENT = '[tex]/verb'; Locale.registerLocaleFiles(COMPONENT, '../ts/input/tex/verb'); +Locale.registerMessages(COMPONENT, 'en', data); diff --git a/ts/ui/menu/__locales__/Component.ts b/ts/ui/menu/__locales__/Component.ts index fbd032936..bc07579fc 100644 --- a/ts/ui/menu/__locales__/Component.ts +++ b/ts/ui/menu/__locales__/Component.ts @@ -22,10 +22,12 @@ */ import { Locale, namedData } from '../../../util/Locale.js'; +import data from './en.json' with {type: 'json'}; export const COMPONENT = 'ui/menu'; Locale.registerLocaleFiles(COMPONENT, '../ts/ui/menu'); +Locale.registerMessages(COMPONENT, 'en', data); /** * Get a localized message for this component diff --git a/ts/util/Locale.ts b/ts/util/Locale.ts index 20e442a2f..a3455253d 100644 --- a/ts/util/Locale.ts +++ b/ts/util/Locale.ts @@ -21,6 +21,8 @@ * @author dpvc@mathjax.org (Davide Cervone) */ +import en from './Locale/__locales__/en.json' with {type: 'json'}; + /** * The various object map types */ @@ -29,6 +31,11 @@ export type localeData = { [locale: string]: messageData }; export type componentData = { [component: string]: localeData }; export type namedData = { [name: string | number]: string }; +/** + * The Locale utility component + */ +export const COMPONENT = 'locale'; + /** * The Locale class for handling localized messages */ @@ -59,20 +66,7 @@ export class Locale { * The localized message strings, per component and locale, * with the default message for localeError() below. */ - protected static data: componentData = { - locale: { - en: { - LocaleJsonError: "MathJax(%1): Can't load '%2': %3", - LocaleMessageNotFound: - "MathJax(Locale): No localized or default version for message with id '%1' from '%2'", - }, - de: { - LocaleJsonError: "MathJax(%1): '%2' kann nicht geladen werden: %3", - LocaleMessageNotFound: - "MathJax(Locale): Keine lokalisierte oder Standardversion für die Meldung mit der ID '%1' aus '%2'", - }, - }, - }; + protected static data: componentData = {}; /** * The locale files to load for each locale (as registered by the components) @@ -90,10 +84,12 @@ export class Locale { component: string, prefix: string = component ) { - this.locations[component] = [ - `${this.isComponent ? component : prefix}/__locales__`, - new Set(), - ]; + if (!this.locations[component]) { + this.locations[component] = [ + `${this.isComponent ? component : prefix}/__locales__`, + new Set(), + ]; + } } /** @@ -109,6 +105,10 @@ export class Locale { locale: string, data: messageData ) { + if (!this.locations[component]) { + this.warn(COMPONENT, 'NoComponent', component); + return; + } if (!this.data[component]) { this.data[component] = Object.create(null); } @@ -186,8 +186,8 @@ export class Locale { this.data[component]?.[this.current]?.[id] || this.data[component]?.[this.default]?.[id] || this.substituteArguments( - this.data.locale[this.current]?.['LocaleMessageNotFound'] || - this.data.locale[this.default]?.['LocaleMessageNotFound'] || + this.data[COMPONENT][this.current]?.['MessageNotFound'] || + this.data[COMPONENT][this.default]?.['MessageNotFound'] || '', { 1: id, 2: component } ) @@ -257,7 +257,6 @@ export class Locale { public static async setLocale( locale: string = this.current ): Promise { - this.initialized = true; if (!this.syncLoad && !this.asyncLoad) { const { mathjax } = await import('../mathjax.js'); if (mathjax.asyncIsSynchronous) { @@ -328,8 +327,8 @@ export class Locale { error: Error ): Promise | void { const message = this.message( - 'locale', - 'LocaleJsonError', + COMPONENT, + 'JsonError', component, `${locale}.json`, error.message @@ -351,3 +350,6 @@ export class Locale { } } } + +Locale.registerLocaleFiles(COMPONENT, '../ts/util/Locale'); +Locale.registerMessages(COMPONENT, 'en', en); diff --git a/ts/util/Locale/__locales__/de.json b/ts/util/Locale/__locales__/de.json new file mode 100644 index 000000000..904efee5e --- /dev/null +++ b/ts/util/Locale/__locales__/de.json @@ -0,0 +1,5 @@ +{ + "JsonError": "MathJax(%1): '%2' kann nicht geladen werden: %3", + "MessageNotFound": "MathJax(Locale): Keine lokalisierte oder Standardversion für die Meldung mit der ID '%1' aus '%2'", + "NoComponent": "MathJax(Locale): Die Komponente '%1' existiert nicht" +} diff --git a/ts/util/Locale/__locales__/en.json b/ts/util/Locale/__locales__/en.json new file mode 100644 index 000000000..d86d29ece --- /dev/null +++ b/ts/util/Locale/__locales__/en.json @@ -0,0 +1,5 @@ +{ + "JsonError": "MathJax(%1): Can't load '%2': %3", + "MessageNotFound": "MathJax(Locale): No localized or default version for message with id '%1' from '%2'", + "NoComponent": "MathJax(Locale): Component '%1' doesn't exist" +}