UNPKG

@hug/ngx-g11n

Version:

Angular helpers for internationalizing and localizing your application

55 lines (50 loc) 2.03 kB
import * as i0 from '@angular/core'; import { inject, LOCALE_ID, makeEnvironmentProviders, NgModule } from '@angular/core'; import { provideHttpClient, withInterceptors } 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'; const withInterceptor = () => ({ providers: [ provideHttpClient(withInterceptors([ (req, next) => { const headers = req.headers.set('Accept-Language', inject(LOCALE_ID)); return next(req.clone({ headers })); } ])) ] }); const withLocales = (locales) => ({ providers: [ { provide: LOCALES, useValue: locales } ] }); const withOptions = (options) => ({ providers: [ { provide: G11N_OPTIONS, useValue: { ...DEFAULT_OPTIONS, ...options } } ] }); const provideG11n = (...features) => makeEnvironmentProviders([ init(), features.map(feature => feature.providers) ]); class G11nModule { static forRoot(...features) { return { ngModule: G11nModule, providers: [ provideG11n(...features) ] }; } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.7", ngImport: i0, type: G11nModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); } static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.7", ngImport: i0, type: G11nModule }); } static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.7", ngImport: i0, type: G11nModule }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.7", ngImport: i0, type: G11nModule, decorators: [{ type: NgModule }] }); /** * Generated bundle index. Do not edit. */ export { G11nModule, provideG11n, withInterceptor, withLocales, withOptions }; //# sourceMappingURL=hug-ngx-g11n.mjs.map