TranslateLoader API
This content is for v15. Switch to the latest version for up-to-date documentation.
Translate Loader API
The loader is responsible for providing translations to the application. It can deliver either embedded translations or load them from a server.
There are several loaders already available as plugins. So in most
cases, you’ll not need to create your own. See Installation
on how to use the default loader @ngx-translate/http-loader
.
You might also find 3rd party loaders in the plugins section.
The TranslateModule
can be configured with a loader which loads translation
files at runtime.
To implement your own loader, create a class derived from this interface:
The getTranslation()
receives the language code as input and
has to return a promise the resolves to a translation object.
To configure the TranslateModule
to use your loader
change the configuration in TranslateModule.forRoot()
:
If you are using the HttpClient
, use a factory method to initialise it: