Fix hotkey translations

This commit is contained in:
Chocobozzz 2018-10-03 10:11:26 +02:00
parent 60709df536
commit e33f888b86
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
4 changed files with 20 additions and 16 deletions

View File

@ -8,6 +8,7 @@ import { Subscription } from 'rxjs'
import { AuthService } from '@app/core' import { AuthService } from '@app/core'
import { Hotkey, HotkeysService } from 'angular2-hotkeys' import { Hotkey, HotkeysService } from 'angular2-hotkeys'
import { SubscribeButtonComponent } from '@app/shared/user-subscription/subscribe-button.component' import { SubscribeButtonComponent } from '@app/shared/user-subscription/subscribe-button.component'
import { I18n } from '@ngx-translate/i18n-polyfill'
@Component({ @Component({
templateUrl: './video-channels.component.html', templateUrl: './video-channels.component.html',
@ -22,6 +23,7 @@ export class VideoChannelsComponent implements OnInit, OnDestroy {
private routeSub: Subscription private routeSub: Subscription
constructor ( constructor (
private i18n: I18n,
private route: ActivatedRoute, private route: ActivatedRoute,
private authService: AuthService, private authService: AuthService,
private videoChannelService: VideoChannelService, private videoChannelService: VideoChannelService,
@ -45,7 +47,7 @@ export class VideoChannelsComponent implements OnInit, OnDestroy {
this.subscribeButton.unsubscribe() : this.subscribeButton.unsubscribe() :
this.subscribeButton.subscribe() this.subscribeButton.subscribe()
return false return false
}, undefined, 'Subscribe to the account') }, undefined, this.i18n('Subscribe to the account'))
] ]
if (this.isUserLoggedIn()) this.hotkeysService.add(this.hotkeys) if (this.isUserLoggedIn()) this.hotkeysService.add(this.hotkeys)
} }

View File

@ -6,6 +6,7 @@ import { is18nPath } from '../../../shared/models/i18n'
import { ScreenService } from '@app/shared/misc/screen.service' import { ScreenService } from '@app/shared/misc/screen.service'
import { skip } from 'rxjs/operators' import { skip } from 'rxjs/operators'
import { HotkeysService, Hotkey } from 'angular2-hotkeys' import { HotkeysService, Hotkey } from 'angular2-hotkeys'
import { I18n } from '@ngx-translate/i18n-polyfill'
@Component({ @Component({
selector: 'my-app', selector: 'my-app',
@ -31,6 +32,7 @@ export class AppComponent implements OnInit {
customCSS: SafeHtml customCSS: SafeHtml
constructor ( constructor (
private i18n: I18n,
private router: Router, private router: Router,
private authService: AuthService, private authService: AuthService,
private serverService: ServerService, private serverService: ServerService,
@ -133,35 +135,35 @@ export class AppComponent implements OnInit {
new Hotkey(['/', 's'], (event: KeyboardEvent): boolean => { new Hotkey(['/', 's'], (event: KeyboardEvent): boolean => {
document.getElementById('search-video').focus() document.getElementById('search-video').focus()
return false return false
}, undefined, 'Focus the search bar'), }, undefined, this.i18n('Focus the search bar')),
new Hotkey('b', (event: KeyboardEvent): boolean => { new Hotkey('b', (event: KeyboardEvent): boolean => {
this.toggleMenu() this.toggleMenu()
return false return false
}, undefined, 'Toggle the left menu'), }, undefined, this.i18n('Toggle the left menu')),
new Hotkey('g o', (event: KeyboardEvent): boolean => { new Hotkey('g o', (event: KeyboardEvent): boolean => {
this.router.navigate([ '/videos/overview' ]) this.router.navigate([ '/videos/overview' ])
return false return false
}, undefined, 'Go to the videos overview page'), }, undefined, this.i18n('Go to the videos overview page')),
new Hotkey('g t', (event: KeyboardEvent): boolean => { new Hotkey('g t', (event: KeyboardEvent): boolean => {
this.router.navigate([ '/videos/trending' ]) this.router.navigate([ '/videos/trending' ])
return false return false
}, undefined, 'Go to the trending videos page'), }, undefined, this.i18n('Go to the trending videos page')),
new Hotkey('g r', (event: KeyboardEvent): boolean => { new Hotkey('g r', (event: KeyboardEvent): boolean => {
this.router.navigate([ '/videos/recently-added' ]) this.router.navigate([ '/videos/recently-added' ])
return false return false
}, undefined, 'Go to the recently added videos page'), }, undefined, this.i18n('Go to the recently added videos page')),
new Hotkey('g l', (event: KeyboardEvent): boolean => { new Hotkey('g l', (event: KeyboardEvent): boolean => {
this.router.navigate([ '/videos/local' ]) this.router.navigate([ '/videos/local' ])
return false return false
}, undefined, 'Go to the local videos page'), }, undefined, this.i18n('Go to the local videos page')),
new Hotkey('g u', (event: KeyboardEvent): boolean => { new Hotkey('g u', (event: KeyboardEvent): boolean => {
this.router.navigate([ '/videos/upload' ]) this.router.navigate([ '/videos/upload' ])
return false return false
}, undefined, 'Go to the videos upload page'), }, undefined, this.i18n('Go to the videos upload page')),
new Hotkey('shift+t', (event: KeyboardEvent): boolean => { new Hotkey('shift+t', (event: KeyboardEvent): boolean => {
this.themeService.toggleDarkTheme() this.themeService.toggleDarkTheme()
return false return false
}, undefined, 'Toggle Dark theme') }, undefined, this.i18n('Toggle Dark theme'))
]) ])
} }

View File

@ -65,19 +65,19 @@ export class AuthService {
new Hotkey('m s', (event: KeyboardEvent): boolean => { new Hotkey('m s', (event: KeyboardEvent): boolean => {
this.router.navigate([ '/videos/subscriptions' ]) this.router.navigate([ '/videos/subscriptions' ])
return false return false
}, undefined, 'Go to my subscriptions'), }, undefined, this.i18n('Go to my subscriptions')),
new Hotkey('m v', (event: KeyboardEvent): boolean => { new Hotkey('m v', (event: KeyboardEvent): boolean => {
this.router.navigate([ '/my-account/videos' ]) this.router.navigate([ '/my-account/videos' ])
return false return false
}, undefined, 'Go to my videos'), }, undefined, this.i18n('Go to my videos')),
new Hotkey('m i', (event: KeyboardEvent): boolean => { new Hotkey('m i', (event: KeyboardEvent): boolean => {
this.router.navigate([ '/my-account/video-imports' ]) this.router.navigate([ '/my-account/video-imports' ])
return false return false
}, undefined, 'Go to my imports'), }, undefined, this.i18n('Go to my imports')),
new Hotkey('m c', (event: KeyboardEvent): boolean => { new Hotkey('m c', (event: KeyboardEvent): boolean => {
this.router.navigate([ '/my-account/video-channels' ]) this.router.navigate([ '/my-account/video-channels' ])
return false return false
}, undefined, 'Go to my channels') }, undefined, this.i18n('Go to my channels'))
] ]
} }

View File

@ -125,17 +125,17 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
new Hotkey('shift+l', (event: KeyboardEvent): boolean => { new Hotkey('shift+l', (event: KeyboardEvent): boolean => {
this.setLike() this.setLike()
return false return false
}, undefined, 'Like the video'), }, undefined, this.i18n('Like the video')),
new Hotkey('shift+d', (event: KeyboardEvent): boolean => { new Hotkey('shift+d', (event: KeyboardEvent): boolean => {
this.setDislike() this.setDislike()
return false return false
}, undefined, 'Dislike the video'), }, undefined, this.i18n('Dislike the video')),
new Hotkey('shift+s', (event: KeyboardEvent): boolean => { new Hotkey('shift+s', (event: KeyboardEvent): boolean => {
this.subscribeButton.subscribed ? this.subscribeButton.subscribed ?
this.subscribeButton.unsubscribe() : this.subscribeButton.unsubscribe() :
this.subscribeButton.subscribe() this.subscribeButton.subscribe()
return false return false
}, undefined, 'Subscribe to the account') }, undefined, this.i18n('Subscribe to the account'))
] ]
if (this.isUserLoggedIn()) this.hotkeysService.add(this.hotkeys) if (this.isUserLoggedIn()) this.hotkeysService.add(this.hotkeys)
} }