@ngx-translate/http-loader
Version:
http loader for dynamically loading translation files for @ngx-translate/core
49 lines (46 loc) • 2.14 kB
TypeScript
import * as i0 from '@angular/core';
import { InjectionToken, Provider } from '@angular/core';
import { TranslateLoader, TranslationObject } from '@ngx-translate/core';
import { Observable } from 'rxjs';
interface TranslateHttpLoaderConfig {
prefix?: string;
suffix?: string;
enforceLoading: boolean;
useHttpBackend: boolean;
/**
* If true, a failed HTTP fetch (e.g. 404) propagates the error and fails
* the whole language load (v17 behaviour). If false (default), each
* resource failure is caught and replaced with an empty object, with a
* `console.warn` per failure; remaining resources still contribute their
* keys. Set this to `true` if you want deploys to fail loudly on a
* missing translation file rather than serve partial translations.
*/
failOnError?: boolean;
}
interface TranslateHttpLoaderResource {
prefix: string;
suffix?: string;
}
interface TranslateMultiHttpLoaderConfig {
resources: (string | TranslateHttpLoaderResource)[];
enforceLoading: boolean;
useHttpBackend: boolean;
/** See {@link TranslateHttpLoaderConfig.failOnError}. */
failOnError?: boolean;
}
declare const TRANSLATE_HTTP_LOADER_CONFIG: InjectionToken<Partial<TranslateMultiHttpLoaderConfig>>;
declare class TranslateHttpLoader implements TranslateLoader {
private http;
private config;
constructor();
/**
* Gets the translations from the server
*/
getTranslation(lang: string): Observable<TranslationObject>;
static ɵfac: i0.ɵɵFactoryDeclaration<TranslateHttpLoader, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<TranslateHttpLoader>;
}
declare function provideTranslateHttpLoader(config?: Partial<TranslateHttpLoaderConfig | TranslateMultiHttpLoaderConfig>): Provider[];
declare function provideTranslateMultiHttpLoader(config?: Partial<TranslateMultiHttpLoaderConfig>): Provider[];
export { TRANSLATE_HTTP_LOADER_CONFIG, TranslateHttpLoader, provideTranslateHttpLoader, provideTranslateMultiHttpLoader };
export type { TranslateHttpLoaderConfig, TranslateHttpLoaderResource, TranslateMultiHttpLoaderConfig };