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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
ResourceStore options doesn't update on instance clone #1974
Comments
i18n.cloneInstance reuses same resources -> so why should the separators be different using same translations?!? |
Better use different instances => https://www.i18next.com/overview/api#createinstance |
The idea is simple. I have a react app, that uses a UI library (also made by me). So I pass to that ui library the Maybe we can create something like |
In my case this is not a good idea as I use remote translations and creating a new instance would mean to lod twice the resources. |
v23.1.0 introduces a new cloneInstance option: const instance = i18n.cloneInstance({
forkResourceStore: true,
keySeparator: '[[my-new-separator]]'
}) |
馃悰 Bug Report
When clone the instance using
i18n.cloneInstance
, theResourceStore
is not cloned with new options.Specifically in my case the
keySeparator
is used from original instance.To Reproduce
Then try to translate a text with the new instance:
When trying to translate with original instance key separator, it does translate.
Cause
I investigated the problem and it is cause by the fact that we create the
ResourceStore
at theinit
, but only when new instance is created, not cloned. So it is initialised only with initial options:i18next/src/i18next.js
Lines 83 to 102 in 18ce83f
The text was updated successfully, but these errors were encountered: