angular-l10n
Version:
An Angular library to translate messages, dates and numbers
47 lines • 1.45 kB
JavaScript
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
*/
import { Injectable, Inject } from "@angular/core";
import { LocaleService } from "../services/locale.service";
import { L10N_CONFIG } from "./l10n-config";
export class LocaleInterceptor {
/**
* @param {?} configuration
* @param {?} locale
*/
constructor(configuration, locale) {
this.configuration = configuration;
this.locale = locale;
}
/**
* @param {?} request
* @param {?} next
* @return {?}
*/
intercept(request, next) {
if (this.configuration.localeInterceptor.format) {
/** @type {?} */
const locale = this.locale.composeLocale(this.configuration.localeInterceptor.format);
if (!!locale) {
request = request.clone({ setHeaders: { 'Accept-Language': locale } });
}
}
return next.handle(request);
}
}
LocaleInterceptor.decorators = [
{ type: Injectable }
];
/** @nocollapse */
LocaleInterceptor.ctorParameters = () => [
{ type: undefined, decorators: [{ type: Inject, args: [L10N_CONFIG,] }] },
{ type: LocaleService }
];
if (false) {
/** @type {?} */
LocaleInterceptor.prototype.configuration;
/** @type {?} */
LocaleInterceptor.prototype.locale;
}
//# sourceMappingURL=locale-interceptor.js.map