Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Q: Have you considered locale specific bundles? #1418

Open
danielkcz opened this issue Apr 2, 2020 · 6 comments
Open

Q: Have you considered locale specific bundles? #1418

danielkcz opened this issue Apr 2, 2020 · 6 comments

Comments

@danielkcz
Copy link

danielkcz commented Apr 2, 2020

I am sorry if I missed this somewhere, I am pretty much new to i18next. I am coming over from LinguiJS which is a neat framework but given its work of a single person, it's growing very slowly, basically stopped now.

There is the RFC for per-locale bundles which ultimately means bundles with minimal to none runtime footprint of localization library. Given that i18next is roughly over 15kB (min+gzip, including React bindings), it would be a significant improvement in my opinion.

Probably best if you read through that RFC, I don't think I can add anything more here as I don't know exact internals of i18next. Would it be something you would consider working on? Do you think it would be even possible?

@jamuhl
Copy link
Member

jamuhl commented Apr 2, 2020

i18next is mainly maintained by one person too (but has nowadays a fallback strategy) - but constantly over 10 years. The problem with creating such modules is you have to stay committed - which understandable can be hard at some time (we finally came over this by creating a company and a product supporting i18next -> locize.com)

Generating a build output per language...sounds good. It's more or less the approach angular does with it's AOT compiler.

It's absolutely doable...we do something similar with https://github.com/i18next/i18nextify -> auto instrument HTML pages. While it's a different source and result -> something similar should be possible during bundling using webpack.

It's more a problem of knowing webpack and how to write a plugin doing the change for elements containing text and some HTML attributes on the elements.

Another idea I would love to see implemented is extending react-dom reconciler to enable auto instrumentation of the text nodes -> translatable out of the box.

So, possible? - for sure. Would I consider working on it - not really - I would support someone willing to do this...like I did eg. for next-i18next - but I'm not willing doing it fully on my own time...

@danielkcz
Copy link
Author

Would I consider working on it - not really

Fair enough. It's not some immediate pain for me either. I am at the beginning of building my own product and I am just thinking ahead where might be possible bottlenecks for performance (especially first time load).

Can we keep the issue open for a while (there aren't many open) just in case someone finds it interesting and wants to dive in?

@jamuhl
Copy link
Member

jamuhl commented Apr 2, 2020

sure...I tagged it for help wanted

@re-thc
Copy link

re-thc commented Aug 22, 2020

It's not using a bundler but can't this already be achieved with the fetch / axios backend? Or does it work differently?

@rosskevin
Copy link
Collaborator

I think this is possible with vite and named exports + dynamic imports. This should be chunkable/tree shakeable. Another option with vite would be to investigate how they are handling json and emulate the same. I documented my thoughts in issue for the new vite-plugin I just forked from our old webpack loader @alienfast/i18next-loader.

@NuclleaR
Copy link

Hello!
I just want to ask or share my thoughts. the Dynamic import, in this case, is cool, only the proper location could be loaded but the drawback of that solution is that I need to load my main bundle to start loading the locale, but to speed up loading how to load that in parallel? Or for today the only solution is to create language-specific bundles?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants