Install the library using Angular CLI:
As part of the installation process you'll be presented with questions; Once you answer them, everything you need will automatically be created for you. Let's take a closer look at the generated files:
First, Transloco creates boilerplate files for the requested translations:
Next, it will create a new file,
transloco-root.module.ts which exposes an Angular's module with a default configuration, and inject it into the
As you might have noticed it also set an
HttpLoader into the module's providers. The
HttpLoader is a class that implements the
TranslocoLoader interface. It's responsible for instructing Transloco how to load the translation files. It uses Angular HTTP client to fetch the files, based on the given path (We'll see why it called path on the lazy load section).
When you deploy your application and Transloco is unable to load your language files it might because you need to use a relative path:
And that's it! Now we are ready to use it in our project.