From eaa529528cafcfb291009f9f99d296c81e792899 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 24 May 2022 16:29:01 +0200 Subject: Support ICU in TS components --- .../+admin/overview/videos/video-list.component.ts | 41 ++++++++++++++++++---- 1 file changed, 35 insertions(+), 6 deletions(-) (limited to 'client/src/app/+admin/overview/videos') diff --git a/client/src/app/+admin/overview/videos/video-list.component.ts b/client/src/app/+admin/overview/videos/video-list.component.ts index 82ff372aa..67e52d100 100644 --- a/client/src/app/+admin/overview/videos/video-list.component.ts +++ b/client/src/app/+admin/overview/videos/video-list.component.ts @@ -3,6 +3,7 @@ import { finalize } from 'rxjs/operators' import { Component, OnInit, ViewChild } from '@angular/core' import { ActivatedRoute, Router } from '@angular/router' import { AuthService, ConfirmService, Notifier, RestPagination, RestTable } from '@app/core' +import { prepareIcu } from '@app/helpers' import { AdvancedInputFilter } from '@app/shared/shared-forms' import { DropdownAction, Video, VideoService } from '@app/shared/shared-main' import { VideoBlockComponent, VideoBlockService } from '@app/shared/shared-moderation' @@ -196,14 +197,24 @@ export class VideoListComponent extends RestTable implements OnInit { } private async removeVideos (videos: Video[]) { - const message = $localize`Are you sure you want to delete these ${videos.length} videos?` + const message = prepareIcu($localize`Are you sure you want to delete {count, plural, =1 {this video} other {these {count} videos}}?`)( + { count: videos.length }, + $localize`Are you sure you want to delete these ${videos.length} videos?` + ) + const res = await this.confirmService.confirm(message, $localize`Delete`) if (res === false) return this.videoService.removeVideo(videos.map(v => v.id)) .subscribe({ next: () => { - this.notifier.success($localize`Deleted ${videos.length} videos.`) + this.notifier.success( + prepareIcu($localize`Deleted {count, plural, =1 {1 video} other {{count} videos}}.`)( + { count: videos.length }, + $localize`Deleted ${videos.length} videos.` + ) + ) + this.reloadData() }, @@ -215,7 +226,13 @@ export class VideoListComponent extends RestTable implements OnInit { this.videoBlockService.unblockVideo(videos.map(v => v.id)) .subscribe({ next: () => { - this.notifier.success($localize`Unblocked ${videos.length} videos.`) + this.notifier.success( + prepareIcu($localize`Unblocked {count, plural, =1 {1 video} other {{count} videos}}.`)( + { count: videos.length }, + $localize`Unblocked ${videos.length} videos.` + ) + ) + this.reloadData() }, @@ -224,9 +241,21 @@ export class VideoListComponent extends RestTable implements OnInit { } private async removeVideoFiles (videos: Video[], type: 'hls' | 'webtorrent') { - const message = type === 'hls' - ? $localize`Are you sure you want to delete ${videos.length} HLS streaming playlists?` - : $localize`Are you sure you want to delete WebTorrent files of ${videos.length} videos?` + let message: string + + if (type === 'hls') { + // eslint-disable-next-line max-len + message = prepareIcu($localize`Are you sure you want to delete {count, plural, =1 {1 HLS streaming playlist} other {{count} HLS streaming playlists}}?`)( + { count: videos.length }, + $localize`Are you sure you want to delete ${videos.length} HLS streaming playlists?` + ) + } else { + // eslint-disable-next-line max-len + message = prepareIcu($localize`Are you sure you want to delete WebTorrent files of {count, plural, =1 {1 video} other {{count} videos}}?`)( + { count: videos.length }, + $localize`Are you sure you want to delete WebTorrent files of ${videos.length} videos?` + ) + } const res = await this.confirmService.confirm(message, $localize`Delete`) if (res === false) return -- cgit v1.2.3