aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+videos/+video-watch
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-08-12 10:40:04 +0200
committerChocobozzz <me@florianbigard.com>2020-08-14 10:28:30 +0200
commit66357162f8e1227495f09bd4f68446aad7071c6d (patch)
tree7d4429506deb512b2fe1d0267f38a28cda20af55 /client/src/app/+videos/+video-watch
parent8c360747995e17eb5520e22fc3d7bd4c3d26eeee (diff)
downloadPeerTube-66357162f8e1227495f09bd4f68446aad7071c6d.tar.gz
PeerTube-66357162f8e1227495f09bd4f68446aad7071c6d.tar.zst
PeerTube-66357162f8e1227495f09bd4f68446aad7071c6d.zip
Migrate to $localize
* Remove i18n polyfill to translate things in components * Reduce bundle sizes * Improve runtime perf * Reduce a lot the time to make a full client build * Reduce client build complexity * We don't need a service to translate things anymore (so we will be able to translate title pages etc) Unfortunately we may loose some translations in the migration process. I'll put a message on weblate to notify translators
Diffstat (limited to 'client/src/app/+videos/+video-watch')
-rw-r--r--client/src/app/+videos/+video-watch/comment/video-comment.component.ts4
-rw-r--r--client/src/app/+videos/+video-watch/comment/video-comments.component.ts8
-rw-r--r--client/src/app/+videos/+video-watch/recommendations/recommended-videos.component.ts6
-rw-r--r--client/src/app/+videos/+video-watch/video-duration-formatter.pipe.ts11
-rw-r--r--client/src/app/+videos/+video-watch/video-watch-playlist.component.ts12
-rw-r--r--client/src/app/+videos/+video-watch/video-watch.component.ts55
6 files changed, 39 insertions, 57 deletions
diff --git a/client/src/app/+videos/+video-watch/comment/video-comment.component.ts b/client/src/app/+videos/+video-watch/comment/video-comment.component.ts
index 36ec6e9f9..a84e91fd3 100644
--- a/client/src/app/+videos/+video-watch/comment/video-comment.component.ts
+++ b/client/src/app/+videos/+video-watch/comment/video-comment.component.ts
@@ -5,7 +5,6 @@ import { AuthService } from '@app/core/auth'
5import { Account, Actor, DropdownAction, Video } from '@app/shared/shared-main' 5import { Account, Actor, DropdownAction, Video } from '@app/shared/shared-main'
6import { CommentReportComponent } from '@app/shared/shared-moderation/report-modals/comment-report.component' 6import { CommentReportComponent } from '@app/shared/shared-moderation/report-modals/comment-report.component'
7import { VideoComment, VideoCommentThreadTree } from '@app/shared/shared-video-comment' 7import { VideoComment, VideoCommentThreadTree } from '@app/shared/shared-video-comment'
8import { I18n } from '@ngx-translate/i18n-polyfill'
9import { User, UserRight } from '@shared/models' 8import { User, UserRight } from '@shared/models'
10 9
11@Component({ 10@Component({
@@ -39,7 +38,6 @@ export class VideoCommentComponent implements OnInit, OnChanges {
39 commentUser: User 38 commentUser: User
40 39
41 constructor ( 40 constructor (
42 private i18n: I18n,
43 private markdownService: MarkdownService, 41 private markdownService: MarkdownService,
44 private authService: AuthService, 42 private authService: AuthService,
45 private userService: UserService, 43 private userService: UserService,
@@ -138,7 +136,7 @@ export class VideoCommentComponent implements OnInit, OnChanges {
138 if (this.isUserLoggedIn() && this.comment.isDeleted === false && this.authService.getUser().account.id !== this.comment.account.id) { 136 if (this.isUserLoggedIn() && this.comment.isDeleted === false && this.authService.getUser().account.id !== this.comment.account.id) {
139 this.prependModerationActions = [ 137 this.prependModerationActions = [
140 { 138 {
141 label: this.i18n('Report comment'), 139 label: $localize`Report comment`,
142 handler: () => this.showReportModal() 140 handler: () => this.showReportModal()
143 } 141 }
144 ] 142 ]
diff --git a/client/src/app/+videos/+video-watch/comment/video-comments.component.ts b/client/src/app/+videos/+video-watch/comment/video-comments.component.ts
index 66494a20a..517844ab2 100644
--- a/client/src/app/+videos/+video-watch/comment/video-comments.component.ts
+++ b/client/src/app/+videos/+video-watch/comment/video-comments.component.ts
@@ -5,7 +5,6 @@ import { AuthService, ComponentPagination, ConfirmService, hasMoreItems, Notifie
5import { HooksService } from '@app/core/plugins/hooks.service' 5import { HooksService } from '@app/core/plugins/hooks.service'
6import { Syndication, VideoDetails } from '@app/shared/shared-main' 6import { Syndication, VideoDetails } from '@app/shared/shared-main'
7import { VideoComment, VideoCommentService, VideoCommentThreadTree } from '@app/shared/shared-video-comment' 7import { VideoComment, VideoCommentService, VideoCommentThreadTree } from '@app/shared/shared-video-comment'
8import { I18n } from '@ngx-translate/i18n-polyfill'
9 8
10@Component({ 9@Component({
11 selector: 'my-video-comments', 10 selector: 'my-video-comments',
@@ -43,7 +42,6 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy {
43 private confirmService: ConfirmService, 42 private confirmService: ConfirmService,
44 private videoCommentService: VideoCommentService, 43 private videoCommentService: VideoCommentService,
45 private activatedRoute: ActivatedRoute, 44 private activatedRoute: ActivatedRoute,
46 private i18n: I18n,
47 private hooks: HooksService 45 private hooks: HooksService
48 ) {} 46 ) {}
49 47
@@ -162,12 +160,12 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy {
162 let message = 'Do you really want to delete this comment?' 160 let message = 'Do you really want to delete this comment?'
163 161
164 if (commentToDelete.isLocal || this.video.isLocal) { 162 if (commentToDelete.isLocal || this.video.isLocal) {
165 message += this.i18n(' The deletion will be sent to remote instances so they can reflect the change.') 163 message += $localize` The deletion will be sent to remote instances so they can reflect the change.`
166 } else { 164 } else {
167 message += this.i18n(' It is a remote comment, so the deletion will only be effective on your instance.') 165 message += $localize` It is a remote comment, so the deletion will only be effective on your instance.`
168 } 166 }
169 167
170 const res = await this.confirmService.confirm(message, this.i18n('Delete')) 168 const res = await this.confirmService.confirm(message, $localize`Delete`)
171 if (res === false) return 169 if (res === false) return
172 170
173 this.videoCommentService.deleteVideoComment(commentToDelete.videoId, commentToDelete.id) 171 this.videoCommentService.deleteVideoComment(commentToDelete.videoId, commentToDelete.id)
diff --git a/client/src/app/+videos/+video-watch/recommendations/recommended-videos.component.ts b/client/src/app/+videos/+video-watch/recommendations/recommended-videos.component.ts
index d2372023f..a1c8e0661 100644
--- a/client/src/app/+videos/+video-watch/recommendations/recommended-videos.component.ts
+++ b/client/src/app/+videos/+video-watch/recommendations/recommended-videos.component.ts
@@ -4,10 +4,9 @@ import { AuthService, Notifier, SessionStorageService, User, UserService } from
4import { Video } from '@app/shared/shared-main' 4import { Video } from '@app/shared/shared-main'
5import { MiniatureDisplayOptions } from '@app/shared/shared-video-miniature' 5import { MiniatureDisplayOptions } from '@app/shared/shared-video-miniature'
6import { VideoPlaylist } from '@app/shared/shared-video-playlist' 6import { VideoPlaylist } from '@app/shared/shared-video-playlist'
7import { I18n } from '@ngx-translate/i18n-polyfill' 7import { UserLocalStorageKeys } from '@root-helpers/users'
8import { RecommendationInfo } from './recommendation-info.model' 8import { RecommendationInfo } from './recommendation-info.model'
9import { RecommendedVideosStore } from './recommended-videos.store' 9import { RecommendedVideosStore } from './recommended-videos.store'
10import { UserLocalStorageKeys } from '@root-helpers/users'
11 10
12@Component({ 11@Component({
13 selector: 'my-recommended-videos', 12 selector: 'my-recommended-videos',
@@ -38,7 +37,6 @@ export class RecommendedVideosComponent implements OnInit, OnChanges {
38 private userService: UserService, 37 private userService: UserService,
39 private authService: AuthService, 38 private authService: AuthService,
40 private notifier: Notifier, 39 private notifier: Notifier,
41 private i18n: I18n,
42 private store: RecommendedVideosStore, 40 private store: RecommendedVideosStore,
43 private sessionStorageService: SessionStorageService 41 private sessionStorageService: SessionStorageService
44 ) { 42 ) {
@@ -58,7 +56,7 @@ export class RecommendedVideosComponent implements OnInit, OnChanges {
58 ) 56 )
59 } 57 }
60 58
61 this.autoPlayNextVideoTooltip = this.i18n('When active, the next video is automatically played after the current one.') 59 this.autoPlayNextVideoTooltip = $localize`When active, the next video is automatically played after the current one.`
62 } 60 }
63 61
64 ngOnInit () { 62 ngOnInit () {
diff --git a/client/src/app/+videos/+video-watch/video-duration-formatter.pipe.ts b/client/src/app/+videos/+video-watch/video-duration-formatter.pipe.ts
index 4b6767415..19b34f984 100644
--- a/client/src/app/+videos/+video-watch/video-duration-formatter.pipe.ts
+++ b/client/src/app/+videos/+video-watch/video-duration-formatter.pipe.ts
@@ -1,28 +1,23 @@
1import { Pipe, PipeTransform } from '@angular/core' 1import { Pipe, PipeTransform } from '@angular/core'
2import { I18n } from '@ngx-translate/i18n-polyfill'
3 2
4@Pipe({ 3@Pipe({
5 name: 'myVideoDurationFormatter' 4 name: 'myVideoDurationFormatter'
6}) 5})
7export class VideoDurationPipe implements PipeTransform { 6export class VideoDurationPipe implements PipeTransform {
8 7
9 constructor (private i18n: I18n) {
10
11 }
12
13 transform (value: number): string { 8 transform (value: number): string {
14 const hours = Math.floor(value / 3600) 9 const hours = Math.floor(value / 3600)
15 const minutes = Math.floor((value % 3600) / 60) 10 const minutes = Math.floor((value % 3600) / 60)
16 const seconds = value % 60 11 const seconds = value % 60
17 12
18 if (hours > 0) { 13 if (hours > 0) {
19 return this.i18n('{{hours}} h {{minutes}} min {{seconds}} sec', { hours, minutes, seconds }) 14 return $localize`${hours} h ${minutes} min ${seconds} sec`
20 } 15 }
21 16
22 if (minutes > 0) { 17 if (minutes > 0) {
23 return this.i18n('{{minutes}} min {{seconds}} sec', { minutes, seconds }) 18 return $localize`${minutes} min ${seconds} sec`
24 } 19 }
25 20
26 return this.i18n('{{seconds}} sec', { seconds }) 21 return $localize`${seconds} sec`
27 } 22 }
28} 23}
diff --git a/client/src/app/+videos/+video-watch/video-watch-playlist.component.ts b/client/src/app/+videos/+video-watch/video-watch-playlist.component.ts
index 519ce2974..c60ca4671 100644
--- a/client/src/app/+videos/+video-watch/video-watch-playlist.component.ts
+++ b/client/src/app/+videos/+video-watch/video-watch-playlist.component.ts
@@ -1,9 +1,8 @@
1import { Component, Input } from '@angular/core' 1import { Component, Input } from '@angular/core'
2import { Router } from '@angular/router' 2import { Router } from '@angular/router'
3import { AuthService, ComponentPagination, LocalStorageService, Notifier, SessionStorageService, UserService } from '@app/core' 3import { AuthService, ComponentPagination, LocalStorageService, Notifier, SessionStorageService, UserService } from '@app/core'
4import { peertubeLocalStorage, peertubeSessionStorage } from '@root-helpers/peertube-web-storage'
5import { VideoPlaylist, VideoPlaylistElement, VideoPlaylistService } from '@app/shared/shared-video-playlist' 4import { VideoPlaylist, VideoPlaylistElement, VideoPlaylistService } from '@app/shared/shared-video-playlist'
6import { I18n } from '@ngx-translate/i18n-polyfill' 5import { peertubeLocalStorage, peertubeSessionStorage } from '@root-helpers/peertube-web-storage'
7import { VideoDetails, VideoPlaylistPrivacy } from '@shared/models' 6import { VideoDetails, VideoPlaylistPrivacy } from '@shared/models'
8 7
9@Component({ 8@Component({
@@ -36,7 +35,6 @@ export class VideoWatchPlaylistComponent {
36 private userService: UserService, 35 private userService: UserService,
37 private auth: AuthService, 36 private auth: AuthService,
38 private notifier: Notifier, 37 private notifier: Notifier,
39 private i18n: I18n,
40 private videoPlaylist: VideoPlaylistService, 38 private videoPlaylist: VideoPlaylistService,
41 private localStorageService: LocalStorageService, 39 private localStorageService: LocalStorageService,
42 private sessionStorageService: SessionStorageService, 40 private sessionStorageService: SessionStorageService,
@@ -189,13 +187,13 @@ export class VideoWatchPlaylistComponent {
189 187
190 private setAutoPlayNextVideoPlaylistSwitchText () { 188 private setAutoPlayNextVideoPlaylistSwitchText () {
191 this.autoPlayNextVideoPlaylistSwitchText = this.autoPlayNextVideoPlaylist 189 this.autoPlayNextVideoPlaylistSwitchText = this.autoPlayNextVideoPlaylist
192 ? this.i18n('Stop autoplaying next video') 190 ? $localize`Stop autoplaying next video`
193 : this.i18n('Autoplay next video') 191 : $localize`Autoplay next video`
194 } 192 }
195 193
196 private setLoopPlaylistSwitchText () { 194 private setLoopPlaylistSwitchText () {
197 this.loopPlaylistSwitchText = this.loopPlaylist 195 this.loopPlaylistSwitchText = this.loopPlaylist
198 ? this.i18n('Stop looping playlist videos') 196 ? $localize`Stop looping playlist videos`
199 : this.i18n('Loop playlist videos') 197 : $localize`Loop playlist videos`
200 } 198 }
201} 199}
diff --git a/client/src/app/+videos/+video-watch/video-watch.component.ts b/client/src/app/+videos/+video-watch/video-watch.component.ts
index a53af210a..fb89bf6cd 100644
--- a/client/src/app/+videos/+video-watch/video-watch.component.ts
+++ b/client/src/app/+videos/+video-watch/video-watch.component.ts
@@ -14,7 +14,6 @@ import { SubscribeButtonComponent } from '@app/shared/shared-user-subscription'
14import { VideoDownloadComponent } from '@app/shared/shared-video-miniature' 14import { VideoDownloadComponent } from '@app/shared/shared-video-miniature'
15import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist' 15import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist'
16import { MetaService } from '@ngx-meta/core' 16import { MetaService } from '@ngx-meta/core'
17import { I18n } from '@ngx-translate/i18n-polyfill'
18import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' 17import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'
19import { ServerConfig, UserVideoRateType, VideoCaption, VideoPrivacy, VideoState } from '@shared/models' 18import { ServerConfig, UserVideoRateType, VideoCaption, VideoPrivacy, VideoState } from '@shared/models'
20import { getStoredP2PEnabled, getStoredTheater } from '../../../assets/player/peertube-player-local-storage' 19import { getStoredP2PEnabled, getStoredTheater } from '../../../assets/player/peertube-player-local-storage'
@@ -97,16 +96,15 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
97 private zone: NgZone, 96 private zone: NgZone,
98 private redirectService: RedirectService, 97 private redirectService: RedirectService,
99 private videoCaptionService: VideoCaptionService, 98 private videoCaptionService: VideoCaptionService,
100 private i18n: I18n,
101 private hotkeysService: HotkeysService, 99 private hotkeysService: HotkeysService,
102 private hooks: HooksService, 100 private hooks: HooksService,
103 private location: PlatformLocation, 101 private location: PlatformLocation,
104 @Inject(LOCALE_ID) private localeId: string 102 @Inject(LOCALE_ID) private localeId: string
105 ) { 103 ) {
106 this.tooltipLike = this.i18n('Like this video') 104 this.tooltipLike = $localize`Like this video`
107 this.tooltipDislike = this.i18n('Dislike this video') 105 this.tooltipDislike = $localize`Dislike this video`
108 this.tooltipSupport = this.i18n('Support options for this video') 106 this.tooltipSupport = $localize`Support options for this video`
109 this.tooltipSaveToPlaylist = this.i18n('Save to playlist') 107 this.tooltipSaveToPlaylist = $localize`Save to playlist`
110 } 108 }
111 109
112 get user () { 110 get user () {
@@ -188,7 +186,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
188 getRatePopoverText () { 186 getRatePopoverText () {
189 if (this.isUserLoggedIn()) return undefined 187 if (this.isUserLoggedIn()) return undefined
190 188
191 return this.i18n('You need to be connected to rate this content.') 189 return $localize`You need to be connected to rate this content.`
192 } 190 }
193 191
194 showMoreDescription () { 192 showMoreDescription () {
@@ -409,10 +407,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
409 } 407 }
410 408
411 private setVideoLikesBarTooltipText () { 409 private setVideoLikesBarTooltipText () {
412 this.likesBarTooltipText = this.i18n('{{likesNumber}} likes / {{dislikesNumber}} dislikes', { 410 this.likesBarTooltipText = `${this.video.likes} likes / ${this.video.dislikes} dislikes`
413 likesNumber: this.video.likes,
414 dislikesNumber: this.video.dislikes
415 })
416 } 411 }
417 412
418 private handleError (err: any) { 413 private handleError (err: any) {
@@ -465,8 +460,8 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
465 460
466 if (this.isVideoBlur(this.video)) { 461 if (this.isVideoBlur(this.video)) {
467 const res = await this.confirmService.confirm( 462 const res = await this.confirmService.confirm(
468 this.i18n('This video contains mature or explicit content. Are you sure you want to watch it?'), 463 $localize`This video contains mature or explicit content. Are you sure you want to watch it?`,
469 this.i18n('Mature or explicit content') 464 $localize`Mature or explicit content`
470 ) 465 )
471 if (res === false) return this.location.back() 466 if (res === false) return this.location.back()
472 } 467 }
@@ -515,9 +510,9 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
515 */ 510 */
516 this.player.upnext({ 511 this.player.upnext({
517 timeout: 10000, // 10s 512 timeout: 10000, // 10s
518 headText: this.i18n('Up Next'), 513 headText: $localize`Up Next`,
519 cancelText: this.i18n('Cancel'), 514 cancelText: $localize`Cancel`,
520 suspendedText: this.i18n('Autoplay is suspended'), 515 suspendedText: $localize`Autoplay is suspended`,
521 getTitle: () => this.nextVideoTitle, 516 getTitle: () => this.nextVideoTitle,
522 next: () => this.zone.run(() => this.autoplayNext()), 517 next: () => this.zone.run(() => this.autoplayNext()),
523 condition: () => { 518 condition: () => {
@@ -781,22 +776,22 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
781 private initHotkeys () { 776 private initHotkeys () {
782 this.hotkeys = [ 777 this.hotkeys = [
783 // These hotkeys are managed by the player 778 // These hotkeys are managed by the player
784 new Hotkey('f', e => e, undefined, this.i18n('Enter/exit fullscreen (requires player focus)')), 779 new Hotkey('f', e => e, undefined, $localize`Enter/exit fullscreen (requires player focus)`),
785 new Hotkey('space', e => e, undefined, this.i18n('Play/Pause the video (requires player focus)')), 780 new Hotkey('space', e => e, undefined, $localize`Play/Pause the video (requires player focus)`),
786 new Hotkey('m', e => e, undefined, this.i18n('Mute/unmute the video (requires player focus)')), 781 new Hotkey('m', e => e, undefined, $localize`Mute/unmute the video (requires player focus)`),
787 782
788 new Hotkey('0-9', e => e, undefined, this.i18n('Skip to a percentage of the video: 0 is 0% and 9 is 90% (requires player focus)')), 783 new Hotkey('0-9', e => e, undefined, $localize`Skip to a percentage of the video: 0 is 0% and 9 is 90% (requires player focus)`),
789 784
790 new Hotkey('up', e => e, undefined, this.i18n('Increase the volume (requires player focus)')), 785 new Hotkey('up', e => e, undefined, $localize`Increase the volume (requires player focus)`),
791 new Hotkey('down', e => e, undefined, this.i18n('Decrease the volume (requires player focus)')), 786 new Hotkey('down', e => e, undefined, $localize`Decrease the volume (requires player focus)`),
792 787
793 new Hotkey('right', e => e, undefined, this.i18n('Seek the video forward (requires player focus)')), 788 new Hotkey('right', e => e, undefined, $localize`Seek the video forward (requires player focus)`),
794 new Hotkey('left', e => e, undefined, this.i18n('Seek the video backward (requires player focus)')), 789 new Hotkey('left', e => e, undefined, $localize`Seek the video backward (requires player focus)`),
795 790
796 new Hotkey('>', e => e, undefined, this.i18n('Increase playback rate (requires player focus)')), 791 new Hotkey('>', e => e, undefined, $localize`Increase playback rate (requires player focus)`),
797 new Hotkey('<', e => e, undefined, this.i18n('Decrease playback rate (requires player focus)')), 792 new Hotkey('<', e => e, undefined, $localize`Decrease playback rate (requires player focus)`),
798 793
799 new Hotkey('.', e => e, undefined, this.i18n('Navigate in the video frame by frame (requires player focus)')) 794 new Hotkey('.', e => e, undefined, $localize`Navigate in the video frame by frame (requires player focus)`)
800 ] 795 ]
801 796
802 if (this.isUserLoggedIn()) { 797 if (this.isUserLoggedIn()) {
@@ -804,17 +799,17 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
804 new Hotkey('shift+l', () => { 799 new Hotkey('shift+l', () => {
805 this.setLike() 800 this.setLike()
806 return false 801 return false
807 }, undefined, this.i18n('Like the video')), 802 }, undefined, $localize`Like the video`),
808 803
809 new Hotkey('shift+d', () => { 804 new Hotkey('shift+d', () => {
810 this.setDislike() 805 this.setDislike()
811 return false 806 return false
812 }, undefined, this.i18n('Dislike the video')), 807 }, undefined, $localize`Dislike the video`),
813 808
814 new Hotkey('shift+s', () => { 809 new Hotkey('shift+s', () => {
815 this.subscribeButton.subscribed ? this.subscribeButton.unsubscribe() : this.subscribeButton.subscribe() 810 this.subscribeButton.subscribed ? this.subscribeButton.unsubscribe() : this.subscribeButton.subscribe()
816 return false 811 return false
817 }, undefined, this.i18n('Subscribe to the account')) 812 }, undefined, $localize`Subscribe to the account`)
818 ]) 813 ])
819 } 814 }
820 815