When working on a feature module or a library (which is common in a monorepo environment), we may want to have the translation files inside the module folder and ship them together with it.
To enable this feature, Transloco supports
scope with inline loaders. We can pass the scope name and an inline loader that leverages Webpack import function to lazy load the local translation files.
Let's say we have the following Angular CLI project:
feature module, we can define the
TRANSLOCO_SCOPE provider and pass an inline loader:
Note that when using an inline loader, the
scope key is used as the
Now we can translate our content using the
scope we define:
And lazy-loaded both the
feature module and its translation files in our application:
Note that following the Angular DI rules, it can be done either in a feature module that we lazy-loaded or at the component providers level.
You can find a complete working example that uses nx here.