import { HttpEvent, HttpHandler, HttpRequest } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { TranslateService } from '@ngx-translate/core'; import { Observable } from 'rxjs'; import { BaseInterceptor } from './base.interceptor'; import { InterceptorType } from './interceptor-type'; @Injectable() export class LocaleInterceptor extends BaseInterceptor { constructor( private language: TranslateService) { super(); } get type(): InterceptorType { return InterceptorType.Locale; } interceptRequest(req: HttpRequest, next: HttpHandler): Observable> { if (this.language.currentLang) { req = req.clone({ headers: req.headers.set('Accept-Language', this.language.currentLang) }); } return next.handle(req); } }