aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+videos/+video-edit/video-add-components
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/video-add-components
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/video-add-components')
-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
3 files changed, 29 insertions, 39 deletions
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