Skip to content

Add localization for mhchem error messages.#1477

Open
dpvc wants to merge 3 commits into
feature/localefrom
feature/mhchem-locale
Open

Add localization for mhchem error messages.#1477
dpvc wants to merge 3 commits into
feature/localefrom
feature/mhchem-locale

Conversation

@dpvc
Copy link
Copy Markdown
Member

@dpvc dpvc commented May 18, 2026

This PR adds localization for the mhchem package, for both English and German. It uses the error id and message thrown by the mhchem parser and translates them into the format needed for the new localized TeXError object. Some of the messages have data inserted into the message strings that has to be extracted to be used as a parameter to TexError, and one of the messages is re-using the [tex]/base message Extra close brace or missing open brace.

I've updated the test file for mhchem, but have not been able to get full coverage. The bond error message actually can never be produced, but I've included it in case the mhchem parser ever changes to permit it. I wasn't able to generate one of the two-parameter bug messages (they seem to be for actual bug conditions, so may not be producible). So the coverage for mhchem is not as complete as it was.

Note that if you add

    json: (file) => import(
      file.replace('/bundle/input/tex/extensions/', '/ts/input/tex/'),
      {with: {type: 'json'}}
    ),

to the lib/v4-lab.js file in the MathJax configuration's loader block (just after require: ... for example), then this will cause the json files to be loaded directly from the ts/input/tex/<package>/__locales__ directory, so you won't have to keep doing the copy script. Also note that

./components/bin/makeAll --copy --terse components/mjs/input/tex/extensions/<package>

will perform the copying to bundle for a given component, while

./components/bin/makeAll --copy --terse components/mjs/input/tex/extensions

would copy all of them.

@dpvc dpvc requested a review from zorkow May 18, 2026 02:22
@dpvc dpvc force-pushed the feature/mhchem-locale branch from 3b5073d to a88ad80 Compare May 18, 2026 22:55
@zorkow zorkow mentioned this pull request May 19, 2026
Copy link
Copy Markdown
Member

@zorkow zorkow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you are registering the wrong locale folder.

Comment thread ts/input/tex/mhchem/__locales__/Component.ts Outdated
Base automatically changed from feature/copy-locales to feature/locale May 19, 2026 19:38
Co-authored-by: Volker Sorge <v.sorge@mathjax.org>
@dpvc
Copy link
Copy Markdown
Member Author

dpvc commented May 19, 2026

I believe you are registering the wrong locale folder.

Thanks for catching that. Copy-and-paste error.

@dpvc dpvc requested a review from zorkow May 19, 2026 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants