Romanchuk / angular-i18next

angular v10+ integration with i18next v19.4+
MIT License
130 stars 33 forks source link

How to load new translations after init #124

Closed sriram275 closed 3 months ago

sriram275 commented 4 months ago

is there we can load translations after init?

This is something like we do customTranslateLoader with ngx-translate TranslateModule.forChild({})

Context is -> We have more angular projects as MFEs and load all in shell where we do initialize i18next. We want to load each project translations after init, is there way we can load translations in feature module.

sriram275 commented 4 months ago

There is way we can add feature module resources using addResourceBundle https://www.i18next.com/overview/api#addresourcebundle But is there way we can dynamically make http call and return that strings.

Romanchuk commented 3 months ago

@sriram275 Option 1: You can easilly get your json by REST call and add it with an addResourceBundle. It is easy. And you can remove it if you need. So you have full control Option 2: Look at i18nextNamespaces in docs in combination with i18next-http-backend. May be this fit for your case. It loads namespaces dynamicaly and it is implemented in the demo app.