-
Hi. Since the package we use for i18n, ngx-translate ,supports loading translation from feature modules, we're looking for a way that let us define them inside the same folder of the feature module so that they would be also available when they're loaded inside the shell. So far the only way I've found to share the translations defined in each remote is the following:
This works, but I don't like the idea of having to manually import every single translation file like I do in step 2. I'd like to find a way to dynamically load the require file using the http client. Something like this:
Unfortunately this is not possible since only static files inside src/assets are served. I also tried adding my new folder to the angular.json file like this, but those files are available during development: Do you know how can I achieve what I describe above or perhaps a better way of exposing the translations (en.json, es.json, etc) each remote defines so that the shell can add them to its own translations? Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hello @axell9641, I had the same problem as you, and I solved it with a custom loader on the shell. Custom loader: Use it in shell app: In the Feature app, translations are available in the regular directory |
Beta Was this translation helpful? Give feedback.
Hello @axell9641, I had the same problem as you, and I solved it with a custom loader on the shell.
Custom loader:
https://github.com/eironman/module-federation-shell/blob/master/src/app/core/language/translate-custom-loader.class.ts
Use it in shell app:
https://github.com/eironman/module-federation-shell/blob/master/src/app/app.module.ts
In the Feature app, translations are available in the regular directory
https://github.com/eironman/module-federation-app-a