Skip to content

React guide: fix the MF2 example and install command, mention i18next-mf2 - #65

Open
adrai wants to merge 3 commits into
unicode-org:mainfrom
i18next:react-guide-fixes
Open

adrai wants to merge 3 commits into
unicode-org:mainfrom
i18next:react-guide-fixes

Conversation

@adrai

@adrai adrai commented Nov 4, 2026

Copy link
Copy Markdown

Hi,

I maintain i18next, react-i18next and i18next-mf2, and went through this page with the current releases (mf2react 0.1.12, messageformat 4.1.0, i18next 26.7.1, react-i18next 17.1.12). This PR fixes what I found:

  • The first example, .match {$count: number}, is not valid MF2. messageformat throws a syntax error (4.1.0, and also 4.0.0-8, which the playground uses), and mf2react then renders the message source. It now declares the variable with .input {$count :number} and selects with .match $count.
  • mf2react 0.1.12 has i18next ^25 and react-i18next ^16 as peer dependencies. In a project that already uses i18next 26 or react-i18next 17, npm install mf2react fails with ERESOLVE, so the install command now names the supported versions.
  • I18nextProvider is optional: initReactI18next already passes the instance to useTranslation and <Trans>, and the examples render without the provider. The layout example also imported { i18n }, while i18n.ts has a default export.
  • The MF2 engine is messageformat. @messageformat/core is the MessageFormat 1 package.
  • A note on the bidi isolation characters around placeholders, and two typos.

I also added a short section on i18next-mf2, the i18next plugin for MF2 that the spec README lists among known implementations, since readers of this page already use i18next. If you'd rather keep the page about mf2react only, I'll drop that commit.

I ran all examples with React 19 and react-dom/server.

cc @izaaksarnecki1: the examples on this page render the same with i18next 26.7.1 and react-i18next 17.1.12, so widening the peer dependency ranges of mf2react would let the install command go back to the latest versions.

Thanks,
Adriano

Copilot AI balanced review requested due to automatic review settings November 4, 2026 14:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The provider-free React guide needs an entry-point ./i18n import so readers who skip the optional layout still initialize translations for useTranslation and <Trans>.

1 open issue
What changed in this PR

Updates the React localization guide with corrected MF2 examples, compatible installation instructions, and an alternative integration using i18next-mf2.

Changes:

  • Fixes MF2 syntax and specifies supported i18next peer-dependency versions.
  • Clarifies optional provider usage, corrects the configuration import, and documents bidi isolation characters.
  • Adds an i18next-mf2 setup and rich-text example, and corrects terminology and package attribution.
File Description
docs/​frameworks/​react.md Corrects React/MF2 setup guidance and adds the alternative i18next plugin integration.

Review effort: Balanced

Comment thread docs/frameworks/react.md Resolved
@adrai

adrai commented Nov 4, 2026

Copy link
Copy Markdown
Author

cc @eemeli, as you were asked to review the original page in #60. It mostly touches the first MF2 example (now .input {$count :number} / .match $count) and names messageformat as the engine instead of @messageformat/core. No rush, whenever you have a moment.

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