]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+admin/overview/videos/video-list.component.ts
Support ICU in TS components
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / overview / videos / video-list.component.ts
index 82ff372aa4252984bf4be7ec73943666544328d6..67e52d100e80cc47c3555fe861f807cb12d43140 100644 (file)
@@ -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