Monday 2 November 2020

How to use data-i18n attributes from older project

I am hoping to upgrade an old project's i18next implementation. The i18n-related code is v1.11, which predates even the breaking changes mentioned for v2.x+

Once upon a time when jQuery was the norm, i18next.js would search the document for translations provided with data-i18n="key" attributes, and fill them in. If you changed languages, you simply called $(parent).i18n() and it would scan the document and fill them in.

I just read the most recent documentation, and they seem to be sticking strictly to the one-key-at-a-time paradigm. No data-attributes, just i18next.t('key').

Have I missed something, or do I need to write my own iterator to go through the document and make the updates? Their code samples seem to indicate "yes", but I have a hard time imagining that anybody sane would want to go through their document and update entries by selector, one-by-one.

To be clear: I'm not asking for a full migration guide. I have headaches ahead of me, this much I know. But I'm hoping I've missed something about using data-i18n attributes, which no longer appear to have built-in support.



from How to use data-i18n attributes from older project

No comments:

Post a Comment