@hug/ngx-g11n
Version:
Angular helpers for internationalizing and localizing your application
63 lines (58 loc) • 2.65 kB
JavaScript
import * as i0 from '@angular/core';
import { inject, LOCALE_ID, Injectable, NgModule } from '@angular/core';
import { HTTP_INTERCEPTORS } from '@angular/common/http';
import { LOCALES, DEFAULT_OPTIONS, G11N_OPTIONS, init } from '@hug/ngx-g11n/internal';
export { G11nDebug, currentLanguage, setLanguage } from '@hug/ngx-g11n/internal';
class G11nInterceptor {
localeId = inject(LOCALE_ID);
intercept(request, next) {
const headers = request.headers.set('Accept-Language', this.localeId);
return next.handle(request.clone({ headers }));
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: G11nInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: G11nInterceptor });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: G11nInterceptor, decorators: [{
type: Injectable
}] });
const withInterceptor = () => ({
providers: [
{ provide: HTTP_INTERCEPTORS, useClass: G11nInterceptor, multi: true, deps: [LOCALE_ID] },
],
});
const withLocales = (locales) => ({
providers: [
{ provide: LOCALES, useValue: locales },
],
});
const withOptions = (options) => ({
providers: [
{ provide: G11N_OPTIONS, useValue: { ...DEFAULT_OPTIONS, rootTranslationsPath: 'assets/translations', ...options } },
],
});
const provideG11n = (...features) => [
init(),
withOptions({ rootTranslationsPath: 'assets/translations' }).providers,
features.map(feature => feature.providers),
];
class G11nModule {
static forRoot(...features) {
return {
ngModule: G11nModule,
providers: [
provideG11n(...features),
],
};
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: G11nModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "22.0.7", ngImport: i0, type: G11nModule });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: G11nModule });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: G11nModule, decorators: [{
type: NgModule
}] });
/**
* Generated bundle index. Do not edit.
*/
export { G11nModule, provideG11n, withInterceptor, withLocales, withOptions };
//# sourceMappingURL=hug-ngx-g11n-legacy.mjs.map