diff options
Diffstat (limited to 'client/src/app/videos/+video-watch/video-watch.component.ts')
-rw-r--r-- | client/src/app/videos/+video-watch/video-watch.component.ts | 41 |
1 files changed, 26 insertions, 15 deletions
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 ad572ef58..f3b4f7a2b 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.ts +++ b/client/src/app/videos/+video-watch/video-watch.component.ts | |||
@@ -23,6 +23,7 @@ import { VideoReportComponent } from './modal/video-report.component' | |||
23 | import { VideoShareComponent } from './modal/video-share.component' | 23 | import { VideoShareComponent } from './modal/video-share.component' |
24 | import { getVideojsOptions } from '../../../assets/player/peertube-player' | 24 | import { getVideojsOptions } from '../../../assets/player/peertube-player' |
25 | import { ServerService } from '@app/core' | 25 | import { ServerService } from '@app/core' |
26 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
26 | 27 | ||
27 | @Component({ | 28 | @Component({ |
28 | selector: 'my-video-watch', | 29 | selector: 'my-video-watch', |
@@ -70,7 +71,8 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
70 | private notificationsService: NotificationsService, | 71 | private notificationsService: NotificationsService, |
71 | private markdownService: MarkdownService, | 72 | private markdownService: MarkdownService, |
72 | private zone: NgZone, | 73 | private zone: NgZone, |
73 | private redirectService: RedirectService | 74 | private redirectService: RedirectService, |
75 | private i18n: I18n | ||
74 | ) {} | 76 | ) {} |
75 | 77 | ||
76 | get user () { | 78 | get user () { |
@@ -153,17 +155,20 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
153 | async blacklistVideo (event: Event) { | 155 | async blacklistVideo (event: Event) { |
154 | event.preventDefault() | 156 | event.preventDefault() |
155 | 157 | ||
156 | const res = await this.confirmService.confirm('Do you really want to blacklist this video?', 'Blacklist') | 158 | const res = await this.confirmService.confirm(this.i18n('Do you really want to blacklist this video?'), this.i18n('Blacklist')) |
157 | if (res === false) return | 159 | if (res === false) return |
158 | 160 | ||
159 | this.videoBlacklistService.blacklistVideo(this.video.id) | 161 | this.videoBlacklistService.blacklistVideo(this.video.id) |
160 | .subscribe( | 162 | .subscribe( |
161 | status => { | 163 | status => { |
162 | this.notificationsService.success('Success', `Video ${this.video.name} had been blacklisted.`) | 164 | this.notificationsService.success( |
165 | this.i18n('Success'), | ||
166 | this.i18n('Video {{ videoName }} had been blacklisted.', { videoName: this.video.name }) | ||
167 | ) | ||
163 | this.redirectService.redirectToHomepage() | 168 | this.redirectService.redirectToHomepage() |
164 | }, | 169 | }, |
165 | 170 | ||
166 | error => this.notificationsService.error('Error', error.message) | 171 | error => this.notificationsService.error(this.i18n('Error'), error.message) |
167 | ) | 172 | ) |
168 | } | 173 | } |
169 | 174 | ||
@@ -198,7 +203,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
198 | 203 | ||
199 | error => { | 204 | error => { |
200 | this.descriptionLoading = false | 205 | this.descriptionLoading = false |
201 | this.notificationsService.error('Error', error.message) | 206 | this.notificationsService.error(this.i18n('Error'), error.message) |
202 | } | 207 | } |
203 | ) | 208 | ) |
204 | } | 209 | } |
@@ -252,19 +257,22 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
252 | async removeVideo (event: Event) { | 257 | async removeVideo (event: Event) { |
253 | event.preventDefault() | 258 | event.preventDefault() |
254 | 259 | ||
255 | const res = await this.confirmService.confirm('Do you really want to delete this video?', 'Delete') | 260 | const res = await this.confirmService.confirm(this.i18n('Do you really want to delete this video?'), this.i18n('Delete')) |
256 | if (res === false) return | 261 | if (res === false) return |
257 | 262 | ||
258 | this.videoService.removeVideo(this.video.id) | 263 | this.videoService.removeVideo(this.video.id) |
259 | .subscribe( | 264 | .subscribe( |
260 | status => { | 265 | status => { |
261 | this.notificationsService.success('Success', `Video ${this.video.name} deleted.`) | 266 | this.notificationsService.success( |
267 | this.i18n('Success'), | ||
268 | this.i18n('Video {{ videoName }} deleted.', { videoName: this.video.name }) | ||
269 | ) | ||
262 | 270 | ||
263 | // Go back to the video-list. | 271 | // Go back to the video-list. |
264 | this.redirectService.redirectToHomepage() | 272 | this.redirectService.redirectToHomepage() |
265 | }, | 273 | }, |
266 | 274 | ||
267 | error => this.notificationsService.error('Error', error.message) | 275 | error => this.notificationsService.error(this.i18n('Error'), error.message) |
268 | ) | 276 | ) |
269 | } | 277 | } |
270 | 278 | ||
@@ -288,7 +296,10 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
288 | } | 296 | } |
289 | 297 | ||
290 | private setVideoLikesBarTooltipText () { | 298 | private setVideoLikesBarTooltipText () { |
291 | this.likesBarTooltipText = `${this.video.likes} likes / ${this.video.dislikes} dislikes` | 299 | this.likesBarTooltipText = this.i18n( |
300 | '{{ likesNumber }} likes / {{ dislikesNumber }} dislikes', | ||
301 | { likesNumber: this.video.likes, dislikes: this.video.dislikes } | ||
302 | ) | ||
292 | } | 303 | } |
293 | 304 | ||
294 | private handleError (err: any) { | 305 | private handleError (err: any) { |
@@ -298,12 +309,12 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
298 | let message = '' | 309 | let message = '' |
299 | 310 | ||
300 | if (errorMessage.indexOf('http error') !== -1) { | 311 | if (errorMessage.indexOf('http error') !== -1) { |
301 | message = 'Cannot fetch video from server, maybe down.' | 312 | message = this.i18n('Cannot fetch video from server, maybe down.') |
302 | } else { | 313 | } else { |
303 | message = errorMessage | 314 | message = errorMessage |
304 | } | 315 | } |
305 | 316 | ||
306 | this.notificationsService.error('Error', message) | 317 | this.notificationsService.error(this.i18n('Error'), message) |
307 | } | 318 | } |
308 | 319 | ||
309 | private checkUserRating () { | 320 | private checkUserRating () { |
@@ -318,7 +329,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
318 | } | 329 | } |
319 | }, | 330 | }, |
320 | 331 | ||
321 | err => this.notificationsService.error('Error', err.message) | 332 | err => this.notificationsService.error(this.i18n('Error'), err.message) |
322 | ) | 333 | ) |
323 | } | 334 | } |
324 | 335 | ||
@@ -333,8 +344,8 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
333 | 344 | ||
334 | if (this.video.isVideoNSFWForUser(this.user, this.serverService.getConfig())) { | 345 | if (this.video.isVideoNSFWForUser(this.user, this.serverService.getConfig())) { |
335 | const res = await this.confirmService.confirm( | 346 | const res = await this.confirmService.confirm( |
336 | 'This video contains mature or explicit content. Are you sure you want to watch it?', | 347 | this.i18n('This video contains mature or explicit content. Are you sure you want to watch it?'), |
337 | 'Mature or explicit content' | 348 | this.i18n('Mature or explicit content') |
338 | ) | 349 | ) |
339 | if (res === false) return this.redirectService.redirectToHomepage() | 350 | if (res === false) return this.redirectService.redirectToHomepage() |
340 | } | 351 | } |
@@ -399,7 +410,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
399 | this.updateVideoRating(this.userRating, nextRating) | 410 | this.updateVideoRating(this.userRating, nextRating) |
400 | this.userRating = nextRating | 411 | this.userRating = nextRating |
401 | }, | 412 | }, |
402 | err => this.notificationsService.error('Error', err.message) | 413 | err => this.notificationsService.error(this.i18n('Error'), err.message) |
403 | ) | 414 | ) |
404 | } | 415 | } |
405 | 416 | ||