|
1 | 1 | import { LANG_ORIGIN, LocaleService } from './locale.service'; |
2 | | -import { Injectable } from '@angular/core'; |
| 2 | +import { Inject, Injectable } from '@angular/core'; |
3 | 3 | import { combineLatest, Observable, of as observableOf } from 'rxjs'; |
4 | 4 | import { map, mergeMap, take } from 'rxjs/operators'; |
5 | | -import { isEmpty, isNotEmpty } from '../../shared/empty.util'; |
| 5 | +import { hasValue, isEmpty, isNotEmpty } from '../../shared/empty.util'; |
| 6 | +import { NativeWindowRef, NativeWindowService } from '../services/window.service'; |
| 7 | +import { REQUEST } from '@nguniversal/express-engine/tokens'; |
| 8 | +import { CookieService } from '../services/cookie.service'; |
| 9 | +import { TranslateService } from '@ngx-translate/core'; |
| 10 | +import { AuthService } from '../auth/auth.service'; |
| 11 | +import { RouteService } from '../services/route.service'; |
| 12 | +import { DOCUMENT } from '@angular/common'; |
6 | 13 |
|
7 | 14 | @Injectable() |
8 | 15 | export class ServerLocaleService extends LocaleService { |
9 | 16 |
|
| 17 | + constructor( |
| 18 | + @Inject(NativeWindowService) protected _window: NativeWindowRef, |
| 19 | + @Inject(REQUEST) protected req: Request, |
| 20 | + protected cookie: CookieService, |
| 21 | + protected translate: TranslateService, |
| 22 | + protected authService: AuthService, |
| 23 | + protected routeService: RouteService, |
| 24 | + @Inject(DOCUMENT) protected document: any |
| 25 | + ) { |
| 26 | + super(_window, cookie, translate, authService, routeService, document); |
| 27 | + } |
| 28 | + |
10 | 29 | /** |
11 | 30 | * Get the languages list of the user in Accept-Language format |
12 | 31 | * |
@@ -50,6 +69,10 @@ export class ServerLocaleService extends LocaleService { |
50 | 69 | if (isNotEmpty(epersonLang)) { |
51 | 70 | languages.push(...epersonLang); |
52 | 71 | } |
| 72 | + if (hasValue(this.req.headers['accept-language'])) { |
| 73 | + languages.push(...this.req.headers['accept-language'].split(',') |
| 74 | + ); |
| 75 | + } |
53 | 76 | return languages; |
54 | 77 | }) |
55 | 78 | ); |
|
0 commit comments