diff options
Diffstat (limited to 'client/src/app/app.component.ts')
-rw-r--r-- | client/src/app/app.component.ts | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts index aba91aad2..c77dc97de 100644 --- a/client/src/app/app.component.ts +++ b/client/src/app/app.component.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { Component, OnInit, ViewChild, AfterViewInit, Inject } from '@angular/core' | 1 | import { Component, OnInit, ViewChild, AfterViewInit, Inject, LOCALE_ID } from '@angular/core' |
2 | import { DomSanitizer, SafeHtml } from '@angular/platform-browser' | 2 | import { DomSanitizer, SafeHtml } from '@angular/platform-browser' |
3 | import { Event, GuardsCheckStart, NavigationEnd, Router, Scroll } from '@angular/router' | 3 | import { Event, GuardsCheckStart, NavigationEnd, Router, Scroll } from '@angular/router' |
4 | import { AuthService, RedirectService, ServerService, ThemeService } from '@app/core' | 4 | import { AuthService, RedirectService, ServerService, ThemeService } from '@app/core' |
@@ -43,6 +43,7 @@ export class AppComponent implements OnInit, AfterViewInit { | |||
43 | 43 | ||
44 | constructor ( | 44 | constructor ( |
45 | @Inject(DOCUMENT) private document: Document, | 45 | @Inject(DOCUMENT) private document: Document, |
46 | @Inject(LOCALE_ID) private localeId: string, | ||
46 | private i18n: I18n, | 47 | private i18n: I18n, |
47 | private viewportScroller: ViewportScroller, | 48 | private viewportScroller: ViewportScroller, |
48 | private router: Router, | 49 | private router: Router, |
@@ -97,6 +98,8 @@ export class AppComponent implements OnInit, AfterViewInit { | |||
97 | this.location.onPopState(() => this.modalService.dismissAll(POP_STATE_MODAL_DISMISS)) | 98 | this.location.onPopState(() => this.modalService.dismissAll(POP_STATE_MODAL_DISMISS)) |
98 | 99 | ||
99 | this.openModalsIfNeeded() | 100 | this.openModalsIfNeeded() |
101 | |||
102 | this.document.documentElement.lang = getShortLocale(this.localeId) | ||
100 | } | 103 | } |
101 | 104 | ||
102 | ngAfterViewInit () { | 105 | ngAfterViewInit () { |
@@ -171,16 +174,6 @@ export class AppComponent implements OnInit, AfterViewInit { | |||
171 | filter(pathname => !pathname || pathname === '/' || is18nPath(pathname)) | 174 | filter(pathname => !pathname || pathname === '/' || is18nPath(pathname)) |
172 | ).subscribe(() => this.redirectService.redirectToHomepage(true)) | 175 | ).subscribe(() => this.redirectService.redirectToHomepage(true)) |
173 | 176 | ||
174 | navigationEndEvent.pipe( | ||
175 | map(() => window.location.pathname), | ||
176 | ).subscribe(pathname => { | ||
177 | if (is18nPath(pathname)) { | ||
178 | this.document.documentElement.lang = getShortLocale(pathname.split('/')[1]) | ||
179 | } else { | ||
180 | this.document.documentElement.lang = 'en' | ||
181 | } | ||
182 | }) | ||
183 | |||
184 | navigationEndEvent.subscribe(e => { | 177 | navigationEndEvent.subscribe(e => { |
185 | this.hooks.runAction('action:router.navigation-end', 'common', { path: e.url }) | 178 | this.hooks.runAction('action:router.navigation-end', 'common', { path: e.url }) |
186 | }) | 179 | }) |