r/reactjs • u/limboo_o • Aug 31 '26
Needs Help I tried removing translation keys from React i18n — Zintl is now in alpha
I've always found translation keys a little strange.
You start with something perfectly readable:
<button>Delete account</button>
Then i18n turns it into something like:
<button>{t("settings.account.delete")}</button>
Now the source code, translation keys, and translation files all have to stay synchronized.
So I tried a different approach with Zintl:
What if the source string itself could be the thing the localization system knows about?
With Zintl, you keep writing normal application code:
<h1>Welcome back</h1>
<p>Your account is ready.</p>
<button>Continue</button>
Zintl's compiler discovers the localizable strings and builds the localization layer around them.
The goal is that adding i18n shouldn't mean rewriting your application around t() calls.
It's currently alpha, so I'm very much not claiming this is production-ready.
I'm looking for React developers who have actually dealt with i18n to try it and tell me where this approach falls apart.
Especially interested in:
- translation key management
- dynamic/interpolated strings
- component boundaries
- pluralization
- large applications
- translation workflows/TMS
- anything you think a compiler like this should handle
Docs: https://zintljs.github.io/zintl/en
I'd genuinely love the criticism. If you think the whole idea is flawed, tell me why.
1
u/phischer_h Aug 31 '26
We are using Lingui in all our apps. I think most things on your list are solved very elegantly in Lingui. https://lingui.dev/
Maybe you can take some inspiration from it.
1
u/tchissin Aug 31 '26
How do you lint or add type safety to translation keys handled this way ?
1
u/OnionPractical7545 Aug 31 '26
identical source strings are a dealbreaker for this approach. You cannot map one English phrase to multiple translations without explicit context markers in the code
1
u/Temperature_Majestic Aug 31 '26
The workflow side is where I'd push. Most TMS tools like Crowdin, Lokalise, Phrase key off a stable string id, and if your identity is source text plus a component or file anchor, then moving a component to a new file or renaming it shifts the anchor and the TMS treats every string in it as new, even when similarityThreshold would have caught a plain text edit. How does the anchor survive a refactor that relocates the component? That plus round-tripping partial translations back from a TMS mid-refactor is the part that bit me on a big app.
1
u/lyeeedar Aug 31 '26
I actually built something exactly like this for my own project. Here's the stuff I had to think about:
You can't do interpolated strings directly, as sentence order my change for other languages. You need a variable system so they can be inserted AFTER translation.
You need to embed the pluralisation into the English source string. E.g. in russian theres 3 ways to write something based on the number. That means you need a 'parseTranslation' helper it runs the text through, or some other kind of runtime hackery.
Sometimes you need context on the strings to disambiguate. E.g.
Stable - system state is good Stable - where you keep horses
I did that with a suffix system. t("Stable", "building")
This approach of having the English be the key does mean that if the English changes you lose the translations. This is especially annoying when there's a lag between the English changing and updated translations being made. I haven't found a decent solution to this one, but I assume some sort of migration flow.
Finally, actually building the scanner. I'm still finding places that were missed and regularly adding them. It's difficult to catch every possible variation that can produce a UI string.
Here's how a translation string looks for mine:
Gain {value} health and {stacks} [stacks | 1 : stack | stacks] of Power
I pass in an object with value and stacks.
Then russian can replace the pluralisation template to hook off the value with whatever crazy rules it wants, and we replace it all at runtime to build the final string
4
u/[deleted] Aug 31 '26
[removed] — view removed comment