angular-l10n
Version:
An Angular library to translate messages, dates and numbers
50 lines • 1.65 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";
var LocaleInterceptor = /** @class */ (function () {
function LocaleInterceptor(configuration, locale) {
this.configuration = configuration;
this.locale = locale;
}
/**
* @param {?} request
* @param {?} next
* @return {?}
*/
LocaleInterceptor.prototype.intercept = /**
* @param {?} request
* @param {?} next
* @return {?}
*/
function (request, next) {
if (this.configuration.localeInterceptor.format) {
/** @type {?} */
var 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 = function () { return [
{ type: undefined, decorators: [{ type: Inject, args: [L10N_CONFIG,] }] },
{ type: LocaleService }
]; };
return LocaleInterceptor;
}());
export { LocaleInterceptor };
if (false) {
/** @type {?} */
LocaleInterceptor.prototype.configuration;
/** @type {?} */
LocaleInterceptor.prototype.locale;
}
//# sourceMappingURL=locale-interceptor.js.map