aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+videos/+video-edit
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-edit
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-edit')
-rw-r--r--client/src/app/+videos/+video-edit/shared/i18n-primeng-calendar.service.ts102
-rw-r--r--client/src/app/+videos/+video-edit/shared/video-edit.component.ts10
-rw-r--r--client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts10
-rw-r--r--client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts10
-rw-r--r--client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts48
-rw-r--r--client/src/app/+videos/+video-edit/video-update.component.ts10
6 files changed, 86 insertions, 104 deletions
diff --git a/client/src/app/+videos/+video-edit/shared/i18n-primeng-calendar.service.ts b/client/src/app/+videos/+video-edit/shared/i18n-primeng-calendar.service.ts
index b05852ff8..2acbace48 100644
--- a/client/src/app/+videos/+video-edit/shared/i18n-primeng-calendar.service.ts
+++ b/client/src/app/+videos/+video-edit/shared/i18n-primeng-calendar.service.ts
@@ -1,76 +1,75 @@
1import { I18n } from '@ngx-translate/i18n-polyfill'
2import { Injectable } from '@angular/core' 1import { Injectable } from '@angular/core'
3 2
4@Injectable() 3@Injectable()
5export class I18nPrimengCalendarService { 4export class I18nPrimengCalendarService {
6 private readonly calendarLocale: any = {} 5 private readonly calendarLocale: any = {}
7 6
8 constructor (private i18n: I18n) { 7 constructor () {
9 this.calendarLocale = { 8 this.calendarLocale = {
10 firstDayOfWeek: 0, 9 firstDayOfWeek: 0,
11 dayNames: [ 10 dayNames: [
12 this.i18n('Sunday'), 11 $localize`Sunday`,
13 this.i18n('Monday'), 12 $localize`Monday`,
14 this.i18n('Tuesday'), 13 $localize`Tuesday`,
15 this.i18n('Wednesday'), 14 $localize`Wednesday`,
16 this.i18n('Thursday'), 15 $localize`Thursday`,
17 this.i18n('Friday'), 16 $localize`Friday`,
18 this.i18n('Saturday') 17 $localize`Saturday`
19 ], 18 ],
20 19
21 dayNamesShort: [ 20 dayNamesShort: [
22 this.i18n({ value: 'Sun', description: 'Day name short' }), 21 $localize`:Day name short:Sun`,
23 this.i18n({ value: 'Mon', description: 'Day name short' }), 22 $localize`:Day name short:Mon`,
24 this.i18n({ value: 'Tue', description: 'Day name short' }), 23 $localize`:Day name short:Tue`,
25 this.i18n({ value: 'Wed', description: 'Day name short' }), 24 $localize`:Day name short:Wed`,
26 this.i18n({ value: 'Thu', description: 'Day name short' }), 25 $localize`:Day name short:Thu`,
27 this.i18n({ value: 'Fri', description: 'Day name short' }), 26 $localize`:Day name short:Fri`,
28 this.i18n({ value: 'Sat', description: 'Day name short' }) 27 $localize`:Day name short:Sat`
29 ], 28 ],
30 29
31 dayNamesMin: [ 30 dayNamesMin: [
32 this.i18n({ value: 'Su', description: 'Day name min' }), 31 $localize`:Day name min:Su`,
33 this.i18n({ value: 'Mo', description: 'Day name min' }), 32 $localize`:Day name min:Mo`,
34 this.i18n({ value: 'Tu', description: 'Day name min' }), 33 $localize`:Day name min:Tu`,
35 this.i18n({ value: 'We', description: 'Day name min' }), 34 $localize`:Day name min:We`,
36 this.i18n({ value: 'Th', description: 'Day name min' }), 35 $localize`:Day name min:Th`,
37 this.i18n({ value: 'Fr', description: 'Day name min' }), 36 $localize`:Day name min:Fr`,
38 this.i18n({ value: 'Sa', description: 'Day name min' }) 37 $localize`:Day name min:Sa`
39 ], 38 ],
40 39
41 monthNames: [ 40 monthNames: [
42 this.i18n('January'), 41 $localize`January`,
43 this.i18n('February'), 42 $localize`February`,
44 this.i18n('March'), 43 $localize`March`,
45 this.i18n('April'), 44 $localize`April`,
46 this.i18n('May'), 45 $localize`May`,
47 this.i18n('June'), 46 $localize`June`,
48 this.i18n('July'), 47 $localize`July`,
49 this.i18n('August'), 48 $localize`August`,
50 this.i18n('September'), 49 $localize`September`,
51 this.i18n('October'), 50 $localize`October`,
52 this.i18n('November'), 51 $localize`November`,
53 this.i18n('December') 52 $localize`December`
54 ], 53 ],
55 54
56 monthNamesShort: [ 55 monthNamesShort: [
57 this.i18n({ value: 'Jan', description: 'Month name short' }), 56 $localize`:Month name short:Jan`,
58 this.i18n({ value: 'Feb', description: 'Month name short' }), 57 $localize`:Month name short:Feb`,
59 this.i18n({ value: 'Mar', description: 'Month name short' }), 58 $localize`:Month name short:Mar`,
60 this.i18n({ value: 'Apr', description: 'Month name short' }), 59 $localize`:Month name short:Apr`,
61 this.i18n({ value: 'May', description: 'Month name short' }), 60 $localize`:Month name short:May`,
62 this.i18n({ value: 'Jun', description: 'Month name short' }), 61 $localize`:Month name short:Jun`,
63 this.i18n({ value: 'Jul', description: 'Month name short' }), 62 $localize`:Month name short:Jul`,
64 this.i18n({ value: 'Aug', description: 'Month name short' }), 63 $localize`:Month name short:Aug`,
65 this.i18n({ value: 'Sep', description: 'Month name short' }), 64 $localize`:Month name short:Sep`,
66 this.i18n({ value: 'Oct', description: 'Month name short' }), 65 $localize`:Month name short:Oct`,
67 this.i18n({ value: 'Nov', description: 'Month name short' }), 66 $localize`:Month name short:Nov`,
68 this.i18n({ value: 'Dec', description: 'Month name short' }) 67 $localize`:Month name short:Dec`
69 ], 68 ],
70 69
71 today: this.i18n('Today'), 70 today: $localize`Today`,
72 71
73 clear: this.i18n('Clear') 72 clear: $localize`Clear`
74 } 73 }
75 } 74 }
76 75
@@ -86,9 +85,6 @@ export class I18nPrimengCalendarService {
86 } 85 }
87 86
88 getDateFormat () { 87 getDateFormat () {
89 return this.i18n({ 88 return $localize`:Date format in this locale.:yy-mm-dd`
90 value: 'yy-mm-dd ',
91 description: 'Date format in this locale.'
92 })
93 } 89 }
94} 90}
diff --git a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts
index ba3b7c96a..050b6d931 100644
--- a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts
+++ b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts
@@ -7,7 +7,6 @@ import { removeElementFromArray } from '@app/helpers'
7import { FormReactiveValidationMessages, FormValidatorService, SelectChannelItem, VideoValidatorsService } from '@app/shared/shared-forms' 7import { FormReactiveValidationMessages, FormValidatorService, SelectChannelItem, VideoValidatorsService } from '@app/shared/shared-forms'
8import { InstanceService } from '@app/shared/shared-instance' 8import { InstanceService } from '@app/shared/shared-instance'
9import { VideoCaptionEdit, VideoEdit, VideoService } from '@app/shared/shared-main' 9import { VideoCaptionEdit, VideoEdit, VideoService } from '@app/shared/shared-main'
10import { I18n } from '@ngx-translate/i18n-polyfill'
11import { ServerConfig, VideoConstant, VideoPrivacy } from '@shared/models' 10import { ServerConfig, VideoConstant, VideoPrivacy } from '@shared/models'
12import { I18nPrimengCalendarService } from './i18n-primeng-calendar.service' 11import { I18nPrimengCalendarService } from './i18n-primeng-calendar.service'
13import { VideoCaptionAddModalComponent } from './video-caption-add-modal.component' 12import { VideoCaptionAddModalComponent } from './video-caption-add-modal.component'
@@ -63,7 +62,6 @@ export class VideoEditComponent implements OnInit, OnDestroy {
63 private serverService: ServerService, 62 private serverService: ServerService,
64 private instanceService: InstanceService, 63 private instanceService: InstanceService,
65 private i18nPrimengCalendarService: I18nPrimengCalendarService, 64 private i18nPrimengCalendarService: I18nPrimengCalendarService,
66 private i18n: I18n,
67 private ngZone: NgZone 65 private ngZone: NgZone
68 ) { 66 ) {
69 this.calendarLocale = this.i18nPrimengCalendarService.getCalendarLocale() 67 this.calendarLocale = this.i18nPrimengCalendarService.getCalendarLocale()
@@ -137,8 +135,8 @@ export class VideoEditComponent implements OnInit, OnDestroy {
137 .subscribe(res => { 135 .subscribe(res => {
138 this.videoLanguages = res.languages 136 this.videoLanguages = res.languages
139 .map(l => res.about.instance.languages.includes(l.id) 137 .map(l => res.about.instance.languages.includes(l.id)
140 ? { ...l, group: this.i18n('Instance languages'), groupOrder: 0 } 138 ? { ...l, group: $localize`Instance languages`, groupOrder: 0 }
141 : { ...l, group: this.i18n('All languages'), groupOrder: 1 }) 139 : { ...l, group: $localize`All languages`, groupOrder: 1 })
142 .sort((a, b) => a.groupOrder - b.groupOrder) 140 .sort((a, b) => a.groupOrder - b.groupOrder)
143 }) 141 })
144 142
@@ -148,8 +146,8 @@ export class VideoEditComponent implements OnInit, OnDestroy {
148 if (this.schedulePublicationPossible) { 146 if (this.schedulePublicationPossible) {
149 this.videoPrivacies.push({ 147 this.videoPrivacies.push({
150 id: this.SPECIAL_SCHEDULED_PRIVACY, 148 id: this.SPECIAL_SCHEDULED_PRIVACY,
151 label: this.i18n('Scheduled'), 149 label: $localize`Scheduled`,
152 description: this.i18n('Hide the video until a specific date') 150 description: $localize`Hide the video until a specific date`
153 }) 151 })
154 } 152 }
155 }) 153 })
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts
index 3a8e6eecc..e9ad8af7a 100644
--- a/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts
+++ b/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts
@@ -4,10 +4,9 @@ import { AuthService, CanComponentDeactivate, Notifier, ServerService } from '@a
4import { scrollToTop } from '@app/helpers' 4import { scrollToTop } from '@app/helpers'
5import { FormValidatorService } from '@app/shared/shared-forms' 5import { FormValidatorService } from '@app/shared/shared-forms'
6import { VideoCaptionService, VideoEdit, VideoImportService, VideoService } from '@app/shared/shared-main' 6import { VideoCaptionService, VideoEdit, VideoImportService, VideoService } from '@app/shared/shared-main'
7import { VideoSend } from './video-send'
8import { LoadingBarService } from '@ngx-loading-bar/core' 7import { LoadingBarService } from '@ngx-loading-bar/core'
9import { I18n } from '@ngx-translate/i18n-polyfill'
10import { VideoPrivacy, VideoUpdate } from '@shared/models' 8import { VideoPrivacy, VideoUpdate } from '@shared/models'
9import { VideoSend } from './video-send'
11 10
12@Component({ 11@Component({
13 selector: 'my-video-import-torrent', 12 selector: 'my-video-import-torrent',
@@ -43,9 +42,8 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Ca
43 protected videoService: VideoService, 42 protected videoService: VideoService,
44 protected videoCaptionService: VideoCaptionService, 43 protected videoCaptionService: VideoCaptionService,
45 private router: Router, 44 private router: Router,
46 private videoImportService: VideoImportService, 45 private videoImportService: VideoImportService
47 private i18n: I18n 46 ) {
48 ) {
49 super() 47 super()
50 } 48 }
51 49
@@ -127,7 +125,7 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Ca
127 .subscribe( 125 .subscribe(
128 () => { 126 () => {
129 this.isUpdatingVideo = false 127 this.isUpdatingVideo = false
130 this.notifier.success(this.i18n('Video to import updated.')) 128 this.notifier.success($localize`Video to import updated.`)
131 129
132 this.router.navigate([ '/my-account', 'video-imports' ]) 130 this.router.navigate([ '/my-account', 'video-imports' ])
133 }, 131 },
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts
index da25663d7..8bad81097 100644
--- a/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts
+++ b/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts
@@ -5,10 +5,9 @@ import { AuthService, CanComponentDeactivate, Notifier, ServerService } from '@a
5import { getAbsoluteAPIUrl, scrollToTop } from '@app/helpers' 5import { getAbsoluteAPIUrl, scrollToTop } from '@app/helpers'
6import { FormValidatorService } from '@app/shared/shared-forms' 6import { FormValidatorService } from '@app/shared/shared-forms'
7import { VideoCaptionService, VideoEdit, VideoImportService, VideoService } from '@app/shared/shared-main' 7import { VideoCaptionService, VideoEdit, VideoImportService, VideoService } from '@app/shared/shared-main'
8import { VideoSend } from './video-send'
9import { LoadingBarService } from '@ngx-loading-bar/core' 8import { LoadingBarService } from '@ngx-loading-bar/core'
10import { I18n } from '@ngx-translate/i18n-polyfill'
11import { VideoPrivacy, VideoUpdate } from '@shared/models' 9import { VideoPrivacy, VideoUpdate } from '@shared/models'
10import { VideoSend } from './video-send'
12 11
13@Component({ 12@Component({
14 selector: 'my-video-import-url', 13 selector: 'my-video-import-url',
@@ -42,9 +41,8 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, CanCom
42 protected videoService: VideoService, 41 protected videoService: VideoService,
43 protected videoCaptionService: VideoCaptionService, 42 protected videoCaptionService: VideoCaptionService,
44 private router: Router, 43 private router: Router,
45 private videoImportService: VideoImportService, 44 private videoImportService: VideoImportService
46 private i18n: I18n 45 ) {
47 ) {
48 super() 46 super()
49 } 47 }
50 48
@@ -137,7 +135,7 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, CanCom
137 .subscribe( 135 .subscribe(
138 () => { 136 () => {
139 this.isUpdatingVideo = false 137 this.isUpdatingVideo = false
140 this.notifier.success(this.i18n('Video to import updated.')) 138 this.notifier.success($localize`Video to import updated.`)
141 139
142 this.router.navigate([ '/my-account', 'video-imports' ]) 140 this.router.navigate([ '/my-account', 'video-imports' ])
143 }, 141 },
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts
index e18e3c9a7..416b655a4 100644
--- a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts
+++ b/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts
@@ -7,7 +7,6 @@ import { scrollToTop } from '@app/helpers'
7import { FormValidatorService } from '@app/shared/shared-forms' 7import { FormValidatorService } from '@app/shared/shared-forms'
8import { BytesPipe, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main' 8import { BytesPipe, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main'
9import { LoadingBarService } from '@ngx-loading-bar/core' 9import { LoadingBarService } from '@ngx-loading-bar/core'
10import { I18n } from '@ngx-translate/i18n-polyfill'
11import { VideoPrivacy } from '@shared/models' 10import { VideoPrivacy } from '@shared/models'
12import { VideoSend } from './video-send' 11import { VideoSend } from './video-send'
13 12
@@ -59,9 +58,8 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
59 protected videoService: VideoService, 58 protected videoService: VideoService,
60 protected videoCaptionService: VideoCaptionService, 59 protected videoCaptionService: VideoCaptionService,
61 private userService: UserService, 60 private userService: UserService,
62 private router: Router, 61 private router: Router
63 private i18n: I18n 62 ) {
64 ) {
65 super() 63 super()
66 } 64 }
67 65
@@ -88,10 +86,10 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
88 86
89 if (this.videoUploaded === true) { 87 if (this.videoUploaded === true) {
90 // FIXME: cannot concatenate strings inside i18n service :/ 88 // FIXME: cannot concatenate strings inside i18n service :/
91 text = this.i18n('Your video was uploaded to your account and is private.') + ' ' + 89 text = $localize`Your video was uploaded to your account and is private.` + ' ' +
92 this.i18n('But associated data (tags, description...) will be lost, are you sure you want to leave this page?') 90 $localize`But associated data (tags, description...) will be lost, are you sure you want to leave this page?`
93 } else { 91 } else {
94 text = this.i18n('Your video is not uploaded yet, are you sure you want to leave this page?') 92 text = $localize`Your video is not uploaded yet, are you sure you want to leave this page?`
95 } 93 }
96 94
97 return { 95 return {
@@ -111,9 +109,9 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
111 109
112 getAudioUploadLabel () { 110 getAudioUploadLabel () {
113 const videofile = this.getVideoFile() 111 const videofile = this.getVideoFile()
114 if (!videofile) return this.i18n('Upload') 112 if (!videofile) return $localize`Upload`
115 113
116 return this.i18n('Upload {{videofileName}}', { videofileName: videofile.name }) 114 return $localize`Upload ${videofile.name}`
117 } 115 }
118 116
119 fileChange () { 117 fileChange () {
@@ -130,7 +128,7 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
130 128
131 this.firstStepError.emit() 129 this.firstStepError.emit()
132 130
133 this.notifier.info(this.i18n('Upload cancelled')) 131 this.notifier.info($localize`Upload cancelled`)
134 } 132 }
135 } 133 }
136 134
@@ -242,7 +240,7 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
242 this.isUpdatingVideo = false 240 this.isUpdatingVideo = false
243 this.isUploadingVideo = false 241 this.isUploadingVideo = false
244 242
245 this.notifier.success(this.i18n('Video published.')) 243 this.notifier.success($localize`Video published.`)
246 this.router.navigate([ '/videos/watch', video.uuid ]) 244 this.router.navigate([ '/videos/watch', video.uuid ])
247 }, 245 },
248 246
@@ -260,14 +258,12 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
260 // Check global user quota 258 // Check global user quota
261 const videoQuota = this.authService.getUser().videoQuota 259 const videoQuota = this.authService.getUser().videoQuota
262 if (videoQuota !== -1 && (this.userVideoQuotaUsed + videofile.size) > videoQuota) { 260 if (videoQuota !== -1 && (this.userVideoQuotaUsed + videofile.size) > videoQuota) {
263 const msg = this.i18n( 261 const videoSizeBytes = bytePipes.transform(videofile.size, 0)
264 'Your video quota is exceeded with this video (video size: {{videoSize}}, used: {{videoQuotaUsed}}, quota: {{videoQuota}})', 262 const videoQuotaUsedBytes = bytePipes.transform(this.userVideoQuotaUsed, 0)
265 { 263 const videoQuotaBytes = bytePipes.transform(videoQuota, 0)
266 videoSize: bytePipes.transform(videofile.size, 0), 264
267 videoQuotaUsed: bytePipes.transform(this.userVideoQuotaUsed, 0), 265 const msg = $localize`Your video quota is exceeded with this video (
268 videoQuota: bytePipes.transform(videoQuota, 0) 266video size: ${videoSizeBytes}, used: ${videoQuotaUsedBytes}, quota: ${videoQuotaBytes})`
269 }
270 )
271 this.notifier.error(msg) 267 this.notifier.error(msg)
272 268
273 return false 269 return false
@@ -282,14 +278,12 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
282 // Check daily user quota 278 // Check daily user quota
283 const videoQuotaDaily = this.authService.getUser().videoQuotaDaily 279 const videoQuotaDaily = this.authService.getUser().videoQuotaDaily
284 if (videoQuotaDaily !== -1 && (this.userVideoQuotaUsedDaily + videofile.size) > videoQuotaDaily) { 280 if (videoQuotaDaily !== -1 && (this.userVideoQuotaUsedDaily + videofile.size) > videoQuotaDaily) {
285 const msg = this.i18n( 281 const videoSizeBytes = bytePipes.transform(videofile.size, 0)
286 'Your daily video quota is exceeded with this video (video size: {{videoSize}}, used: {{quotaUsedDaily}}, quota: {{quotaDaily}})', 282 const quotaUsedDailyBytes = bytePipes.transform(this.userVideoQuotaUsedDaily, 0)
287 { 283 const quotaDailyBytes = bytePipes.transform(videoQuotaDaily, 0)
288 videoSize: bytePipes.transform(videofile.size, 0), 284
289 quotaUsedDaily: bytePipes.transform(this.userVideoQuotaUsedDaily, 0), 285 const msg = $localize`Your daily video quota is exceeded with this video (
290 quotaDaily: bytePipes.transform(videoQuotaDaily, 0) 286video size: ${videoSizeBytes}, used: ${quotaUsedDailyBytes}, quota: ${quotaDailyBytes})`
291 }
292 )
293 this.notifier.error(msg) 287 this.notifier.error(msg)
294 288
295 return false 289 return false
diff --git a/client/src/app/+videos/+video-edit/video-update.component.ts b/client/src/app/+videos/+video-edit/video-update.component.ts
index abd08f05c..2e1d0f89d 100644
--- a/client/src/app/+videos/+video-edit/video-update.component.ts
+++ b/client/src/app/+videos/+video-edit/video-update.component.ts
@@ -5,7 +5,6 @@ import { Notifier } from '@app/core'
5import { FormReactive, FormValidatorService, SelectChannelItem } from '@app/shared/shared-forms' 5import { FormReactive, FormValidatorService, SelectChannelItem } from '@app/shared/shared-forms'
6import { VideoCaptionEdit, VideoCaptionService, VideoDetails, VideoEdit, VideoService } from '@app/shared/shared-main' 6import { VideoCaptionEdit, VideoCaptionService, VideoDetails, VideoEdit, VideoService } from '@app/shared/shared-main'
7import { LoadingBarService } from '@ngx-loading-bar/core' 7import { LoadingBarService } from '@ngx-loading-bar/core'
8import { I18n } from '@ngx-translate/i18n-polyfill'
9import { VideoPrivacy } from '@shared/models' 8import { VideoPrivacy } from '@shared/models'
10 9
11@Component({ 10@Component({
@@ -31,9 +30,8 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
31 private notifier: Notifier, 30 private notifier: Notifier,
32 private videoService: VideoService, 31 private videoService: VideoService,
33 private loadingBar: LoadingBarService, 32 private loadingBar: LoadingBarService,
34 private videoCaptionService: VideoCaptionService, 33 private videoCaptionService: VideoCaptionService
35 private i18n: I18n 34 ) {
36 ) {
37 super() 35 super()
38 } 36 }
39 37
@@ -78,7 +76,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
78 canDeactivate (): { canDeactivate: boolean, text?: string } { 76 canDeactivate (): { canDeactivate: boolean, text?: string } {
79 if (this.updateDone === true) return { canDeactivate: true } 77 if (this.updateDone === true) return { canDeactivate: true }
80 78
81 const text = this.i18n('You have unsaved changes! If you leave, your changes will be lost.') 79 const text = $localize`You have unsaved changes! If you leave, your changes will be lost.`
82 80
83 for (const caption of this.videoCaptions) { 81 for (const caption of this.videoCaptions) {
84 if (caption.action) return { canDeactivate: false, text } 82 if (caption.action) return { canDeactivate: false, text }
@@ -115,7 +113,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
115 this.updateDone = true 113 this.updateDone = true
116 this.isUpdatingVideo = false 114 this.isUpdatingVideo = false
117 this.loadingBar.useRef().complete() 115 this.loadingBar.useRef().complete()
118 this.notifier.success(this.i18n('Video updated.')) 116 this.notifier.success($localize`Video updated.`)
119 this.router.navigate([ '/videos/watch', this.video.uuid ]) 117 this.router.navigate([ '/videos/watch', this.video.uuid ])
120 }, 118 },
121 119