I am making a typescript library that accepts an object and spits out an excel. This library is supposed to be used with several React apps. Each React app[Host] will provide an object and the custom library returns an excel.
All the React apps use i18next for translation. The custom library also needs to use its own set of translations so that also has i18next. I am trying to avoid passing the translation strings from the Host to my library.
Problem:
As soon as I call any function in my library, i18next in the library takes over the i18n of Host. This is expected, As we have two i18next.init() functions [One in my library and one in the host]. Whoever gets called last wins [Library in my case]. All the translation strings in the Host are noted to be missing [by the i18nxt of library] since the newly initialized i18next in the library can't see Host translations.
Question:
How can I approach this problem, if I need to keep i18n on both the library and host? I am expecting both to have their own translations.
I believe you won't need any code to understand the problem.
i18next.createInstance(options, callback) Will return a new i18next instance.This is not what I wanted. I needed a way to append my new resources to an existing instance. I managed to do that if you see the update.init, how does your library actually translate anything? What do you mean "usedi18next.addResourceBundle"? I'm just getting a migraine trying to piece together all the moving parts. I can make things work in React, but nothing I try seems to work in the libraries.