diff options
author | Chocobozzz <me@florianbigard.com> | 2018-06-04 16:21:17 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-06-05 08:43:01 +0200 |
commit | b1d40cff89f7cff565a98cdbcea9a624196a169a (patch) | |
tree | d24746c1cc69f50471a9eba0dfb1c1bae06a1870 /client/src/app/videos/+video-edit/video-add.component.ts | |
parent | 989e526abf0c0dd7958deb630df009608561bb67 (diff) | |
download | PeerTube-b1d40cff89f7cff565a98cdbcea9a624196a169a.tar.gz PeerTube-b1d40cff89f7cff565a98cdbcea9a624196a169a.tar.zst PeerTube-b1d40cff89f7cff565a98cdbcea9a624196a169a.zip |
Add i18n attributes
Diffstat (limited to 'client/src/app/videos/+video-edit/video-add.component.ts')
-rw-r--r-- | client/src/app/videos/+video-edit/video-add.component.ts | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/client/src/app/videos/+video-edit/video-add.component.ts b/client/src/app/videos/+video-edit/video-add.component.ts index 997f033b7..a615fd92c 100644 --- a/client/src/app/videos/+video-edit/video-add.component.ts +++ b/client/src/app/videos/+video-edit/video-add.component.ts | |||
@@ -15,6 +15,7 @@ import { ValidatorMessage } from '../../shared/forms/form-validators/validator-m | |||
15 | import { populateAsyncUserVideoChannels } from '../../shared/misc/utils' | 15 | import { populateAsyncUserVideoChannels } from '../../shared/misc/utils' |
16 | import { VideoEdit } from '../../shared/video/video-edit.model' | 16 | import { VideoEdit } from '../../shared/video/video-edit.model' |
17 | import { VideoService } from '../../shared/video/video.service' | 17 | import { VideoService } from '../../shared/video/video.service' |
18 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
18 | 19 | ||
19 | @Component({ | 20 | @Component({ |
20 | selector: 'my-videos-add', | 21 | selector: 'my-videos-add', |
@@ -56,7 +57,8 @@ export class VideoAddComponent extends FormReactive implements OnInit, OnDestroy | |||
56 | private userService: UserService, | 57 | private userService: UserService, |
57 | private serverService: ServerService, | 58 | private serverService: ServerService, |
58 | private videoService: VideoService, | 59 | private videoService: VideoService, |
59 | private loadingBar: LoadingBarService | 60 | private loadingBar: LoadingBarService, |
61 | private i18n: I18n | ||
60 | ) { | 62 | ) { |
61 | super() | 63 | super() |
62 | } | 64 | } |
@@ -99,10 +101,11 @@ export class VideoAddComponent extends FormReactive implements OnInit, OnDestroy | |||
99 | let text = '' | 101 | let text = '' |
100 | 102 | ||
101 | if (this.videoUploaded === true) { | 103 | if (this.videoUploaded === true) { |
102 | text = 'Your video was uploaded in your account and is private.' + | 104 | // FIXME: cannot concatenate strings inside i18n service :/ |
103 | ' But associated data (tags, description...) will be lost, are you sure you want to leave this page?' | 105 | text = this.i18n('Your video was uploaded in your account and is private.') + |
106 | this.i18n('But associated data (tags, description...) will be lost, are you sure you want to leave this page?') | ||
104 | } else { | 107 | } else { |
105 | text = 'Your video is not uploaded yet, are you sure you want to leave this page?' | 108 | text = this.i18n('Your video is not uploaded yet, are you sure you want to leave this page?') |
106 | } | 109 | } |
107 | 110 | ||
108 | return { | 111 | return { |
@@ -127,7 +130,7 @@ export class VideoAddComponent extends FormReactive implements OnInit, OnDestroy | |||
127 | this.isUploadingVideo = false | 130 | this.isUploadingVideo = false |
128 | this.videoUploadPercents = 0 | 131 | this.videoUploadPercents = 0 |
129 | this.videoUploadObservable = null | 132 | this.videoUploadObservable = null |
130 | this.notificationsService.info('Info', 'Upload cancelled') | 133 | this.notificationsService.info(this.i18n('Info'), this.i18n('Upload cancelled')) |
131 | } | 134 | } |
132 | } | 135 | } |
133 | 136 | ||
@@ -137,7 +140,7 @@ export class VideoAddComponent extends FormReactive implements OnInit, OnDestroy | |||
137 | 140 | ||
138 | // Cannot upload videos > 4GB for now | 141 | // Cannot upload videos > 4GB for now |
139 | if (videofile.size > 4 * 1024 * 1024 * 1024) { | 142 | if (videofile.size > 4 * 1024 * 1024 * 1024) { |
140 | this.notificationsService.error('Error', 'We are sorry but PeerTube cannot handle videos > 4GB') | 143 | this.notificationsService.error(this.i18n('Error'), this.i18n('We are sorry but PeerTube cannot handle videos > 4GB')) |
141 | return | 144 | return |
142 | } | 145 | } |
143 | 146 | ||
@@ -145,11 +148,15 @@ export class VideoAddComponent extends FormReactive implements OnInit, OnDestroy | |||
145 | if (videoQuota !== -1 && (this.userVideoQuotaUsed + videofile.size) > videoQuota) { | 148 | if (videoQuota !== -1 && (this.userVideoQuotaUsed + videofile.size) > videoQuota) { |
146 | const bytePipes = new BytesPipe() | 149 | const bytePipes = new BytesPipe() |
147 | 150 | ||
148 | const msg = 'Your video quota is exceeded with this video ' + | 151 | const msg = this.i18n( |
149 | `(video size: ${bytePipes.transform(videofile.size, 0)}, ` + | 152 | 'Your video quota is exceeded with this video (video size: {{ videoSize }}, used: {{ videoQuotaUsed }}, quota: {{ videoQuota }})', |
150 | `used: ${bytePipes.transform(this.userVideoQuotaUsed, 0)}, ` + | 153 | { |
151 | `quota: ${bytePipes.transform(videoQuota, 0)})` | 154 | videoSize: bytePipes.transform(videofile.size, 0), |
152 | this.notificationsService.error('Error', msg) | 155 | videoQuotaUsed: bytePipes.transform(this.userVideoQuotaUsed, 0), |
156 | videoQuota: bytePipes.transform(videoQuota, 0) | ||
157 | } | ||
158 | ) | ||
159 | this.notificationsService.error(this.i18n('Error'), msg) | ||
153 | return | 160 | return |
154 | } | 161 | } |
155 | 162 | ||
@@ -192,8 +199,6 @@ export class VideoAddComponent extends FormReactive implements OnInit, OnDestroy | |||
192 | if (event.type === HttpEventType.UploadProgress) { | 199 | if (event.type === HttpEventType.UploadProgress) { |
193 | this.videoUploadPercents = Math.round(100 * event.loaded / event.total) | 200 | this.videoUploadPercents = Math.round(100 * event.loaded / event.total) |
194 | } else if (event instanceof HttpResponse) { | 201 | } else if (event instanceof HttpResponse) { |
195 | console.log('Video uploaded.') | ||
196 | |||
197 | this.videoUploaded = true | 202 | this.videoUploaded = true |
198 | 203 | ||
199 | this.videoUploadedIds = event.body.video | 204 | this.videoUploadedIds = event.body.video |
@@ -207,7 +212,7 @@ export class VideoAddComponent extends FormReactive implements OnInit, OnDestroy | |||
207 | this.isUploadingVideo = false | 212 | this.isUploadingVideo = false |
208 | this.videoUploadPercents = 0 | 213 | this.videoUploadPercents = 0 |
209 | this.videoUploadObservable = null | 214 | this.videoUploadObservable = null |
210 | this.notificationsService.error('Error', err.message) | 215 | this.notificationsService.error(this.i18n('Error'), err.message) |
211 | } | 216 | } |
212 | ) | 217 | ) |
213 | } | 218 | } |
@@ -231,13 +236,13 @@ export class VideoAddComponent extends FormReactive implements OnInit, OnDestroy | |||
231 | this.isUploadingVideo = false | 236 | this.isUploadingVideo = false |
232 | this.loadingBar.complete() | 237 | this.loadingBar.complete() |
233 | 238 | ||
234 | this.notificationsService.success('Success', 'Video published.') | 239 | this.notificationsService.success(this.i18n('Success'), this.i18n('Video published.')) |
235 | this.router.navigate([ '/videos/watch', video.uuid ]) | 240 | this.router.navigate([ '/videos/watch', video.uuid ]) |
236 | }, | 241 | }, |
237 | 242 | ||
238 | err => { | 243 | err => { |
239 | this.isUpdatingVideo = false | 244 | this.isUpdatingVideo = false |
240 | this.notificationsService.error('Error', err.message) | 245 | this.notificationsService.error(this.i18n('Error'), err.message) |
241 | console.error(err) | 246 | console.error(err) |
242 | } | 247 | } |
243 | ) | 248 | ) |