diff options
Diffstat (limited to 'client/src/app')
-rw-r--r-- | client/src/app/app.component.ts | 17 | ||||
-rw-r--r-- | client/src/app/header/search-typeahead.component.html | 1 |
2 files changed, 15 insertions, 3 deletions
diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts index a464e90fa..aba91aad2 100644 --- a/client/src/app/app.component.ts +++ b/client/src/app/app.component.ts | |||
@@ -1,13 +1,13 @@ | |||
1 | import { Component, OnInit, ViewChild, AfterViewInit } from '@angular/core' | 1 | import { Component, OnInit, ViewChild, AfterViewInit, Inject } 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' |
5 | import { is18nPath } from '../../../shared/models/i18n' | 5 | import { is18nPath, getShortLocale } from '../../../shared/models/i18n' |
6 | import { ScreenService } from '@app/shared/misc/screen.service' | 6 | import { ScreenService } from '@app/shared/misc/screen.service' |
7 | import { filter, map, pairwise, first } from 'rxjs/operators' | 7 | import { filter, map, pairwise, first } from 'rxjs/operators' |
8 | import { Hotkey, HotkeysService } from 'angular2-hotkeys' | 8 | import { Hotkey, HotkeysService } from 'angular2-hotkeys' |
9 | import { I18n } from '@ngx-translate/i18n-polyfill' | 9 | import { I18n } from '@ngx-translate/i18n-polyfill' |
10 | import { PlatformLocation, ViewportScroller } from '@angular/common' | 10 | import { PlatformLocation, ViewportScroller, DOCUMENT } from '@angular/common' |
11 | import { PluginService } from '@app/core/plugins/plugin.service' | 11 | import { PluginService } from '@app/core/plugins/plugin.service' |
12 | import { HooksService } from '@app/core/plugins/hooks.service' | 12 | import { HooksService } from '@app/core/plugins/hooks.service' |
13 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' | 13 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' |
@@ -42,6 +42,7 @@ export class AppComponent implements OnInit, AfterViewInit { | |||
42 | private serverConfig: ServerConfig | 42 | private serverConfig: ServerConfig |
43 | 43 | ||
44 | constructor ( | 44 | constructor ( |
45 | @Inject(DOCUMENT) private document: Document, | ||
45 | private i18n: I18n, | 46 | private i18n: I18n, |
46 | private viewportScroller: ViewportScroller, | 47 | private viewportScroller: ViewportScroller, |
47 | private router: Router, | 48 | private router: Router, |
@@ -170,6 +171,16 @@ export class AppComponent implements OnInit, AfterViewInit { | |||
170 | filter(pathname => !pathname || pathname === '/' || is18nPath(pathname)) | 171 | filter(pathname => !pathname || pathname === '/' || is18nPath(pathname)) |
171 | ).subscribe(() => this.redirectService.redirectToHomepage(true)) | 172 | ).subscribe(() => this.redirectService.redirectToHomepage(true)) |
172 | 173 | ||
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 | |||
173 | navigationEndEvent.subscribe(e => { | 184 | navigationEndEvent.subscribe(e => { |
174 | this.hooks.runAction('action:router.navigation-end', 'common', { path: e.url }) | 185 | this.hooks.runAction('action:router.navigation-end', 'common', { path: e.url }) |
175 | }) | 186 | }) |
diff --git a/client/src/app/header/search-typeahead.component.html b/client/src/app/header/search-typeahead.component.html index 710268664..6d931db20 100644 --- a/client/src/app/header/search-typeahead.component.html +++ b/client/src/app/header/search-typeahead.component.html | |||
@@ -2,6 +2,7 @@ | |||
2 | <input | 2 | <input |
3 | type="text" id="search-video" name="search-video" #searchVideo i18n-placeholder placeholder="Search videos, channels…" | 3 | type="text" id="search-video" name="search-video" #searchVideo i18n-placeholder placeholder="Search videos, channels…" |
4 | [(ngModel)]="search" (ngModelChange)="onSearchChange()" (keyup)="handleKey($event)" (keydown.enter)="doSearch()" | 4 | [(ngModel)]="search" (ngModelChange)="onSearchChange()" (keyup)="handleKey($event)" (keydown.enter)="doSearch()" |
5 | aria-label="Search" | ||
5 | > | 6 | > |
6 | <span class="icon icon-search" (click)="doSearch()"></span> | 7 | <span class="icon icon-search" (click)="doSearch()"></span> |
7 | 8 | ||