TranslateLoader API
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 @codeandweb/http-loader
.
You might also find 3rd party loaders in the plugins section.
The ngx-translate 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.
Standalone Components
To configure ngx-translate to use your loader
change the configuration in provideTranslationService()
function in your app.config.ts:
If you are using the HttpClient
, use a factory method to initialise it:
ngModules
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: