ngx-translate-multi-http-loader is an Angular-specific HTTP loader for the `@ngx-translate/core` library, designed to fetch translation files from multiple distinct HTTP endpoints. Currently in version 20.0.0, this package typically releases new major versions aligned with Angular's major release cycle, ensuring compatibility with the latest Angular ecosystem. Its primary differentiator is the ability to consolidate translations from various sources (e.g., core application, feature modules, third-party vendors) into a single translation service instance. Crucially, it leverages `HttpBackend` directly instead of `HttpClient`, which allows it to bypass HTTP interceptors by default. This design choice prevents potential delays or conflicts with interceptors that might otherwise interfere with the initial loading of translation files, which often occurs early in the application bootstrap process. It primarily supports JSON format for translation files.
npm install ngx-translate-multi-http-loaderVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates the setup of `MultiTranslateHttpLoader` within an Angular `AppModule`. It configures `@ngx-translate/core` to use `MultiTranslateHttpLoader` with a factory function, loading translations from two distinct `/assets/i18n/` subdirectories, ensuring AoT compatibility and correct dependency injection of `HttpBackend`.
Update your `HttpLoaderFactory` to provide an array of string paths (e.g., `['/assets/i18n/core/', '/assets/i18n/vendors/']`) or `TranslationResource` objects instead of `prefix` and `suffix`. Also, ensure `HttpBackend` is injected, not `HttpClient`.
Always install the version of `ngx-translate-multi-http-loader` that precisely matches your project's Angular major version, as detailed in the package's compatibility table within the README or on npm.
Be aware of this behavior. If specific request headers, authentication, or error handling logic is required for translation file requests, you must implement it directly within the `HttpLoaderFactory` or ensure your `HttpBackend` setup explicitly handles it outside of the `HttpClient` interceptor chain.
Ensure all translation files served from the configured paths are strictly in `.json` format. Other file types or formats will not be parsed correctly.
Ensure `TranslateModule.forRoot` is imported exactly once in your root `AppModule` (or a designated shared module), and that `HttpLoaderFactory` is correctly specified as `useFactory` with `deps: [HttpBackend]` in its loader configuration.
Double-check the array of paths provided to `MultiTranslateHttpLoader` in your `HttpLoaderFactory` (e.g., `['/assets/i18n/core/', '/assets/i18n/vendors/']`) and verify that the corresponding language files (e.g., `en.json`, `fr.json`) exist and are correctly deployed to these locations.
Ensure the parameter in your `HttpLoaderFactory` function is typed as `_httpBackend: HttpBackend` and that `deps: [HttpBackend]` is explicitly configured in `TranslateModule.forRoot` to correctly provide the `HttpBackend` instance.