diff options
author | Chocobozzz <me@florianbigard.com> | 2020-08-12 10:40:04 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-08-14 10:28:30 +0200 |
commit | 66357162f8e1227495f09bd4f68446aad7071c6d (patch) | |
tree | 7d4429506deb512b2fe1d0267f38a28cda20af55 /client/src/app/shared/shared-forms/form-validators/video-validators.service.ts | |
parent | 8c360747995e17eb5520e22fc3d7bd4c3d26eeee (diff) | |
download | PeerTube-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/shared/shared-forms/form-validators/video-validators.service.ts')
-rw-r--r-- | client/src/app/shared/shared-forms/form-validators/video-validators.service.ts | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/client/src/app/shared/shared-forms/form-validators/video-validators.service.ts b/client/src/app/shared/shared-forms/form-validators/video-validators.service.ts index c96e4ef66..8119c1ae7 100644 --- a/client/src/app/shared/shared-forms/form-validators/video-validators.service.ts +++ b/client/src/app/shared/shared-forms/form-validators/video-validators.service.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
2 | import { Validators, ValidatorFn, ValidationErrors, AbstractControl } from '@angular/forms' | ||
3 | import { Injectable } from '@angular/core' | 1 | import { Injectable } from '@angular/core' |
2 | import { AbstractControl, ValidationErrors, ValidatorFn, Validators } from '@angular/forms' | ||
4 | import { BuildFormValidator } from './form-validator.service' | 3 | import { BuildFormValidator } from './form-validator.service' |
5 | 4 | ||
6 | @Injectable() | 5 | @Injectable() |
@@ -19,21 +18,21 @@ export class VideoValidatorsService { | |||
19 | readonly VIDEO_SCHEDULE_PUBLICATION_AT: BuildFormValidator | 18 | readonly VIDEO_SCHEDULE_PUBLICATION_AT: BuildFormValidator |
20 | readonly VIDEO_ORIGINALLY_PUBLISHED_AT: BuildFormValidator | 19 | readonly VIDEO_ORIGINALLY_PUBLISHED_AT: BuildFormValidator |
21 | 20 | ||
22 | constructor (private i18n: I18n) { | 21 | constructor () { |
23 | 22 | ||
24 | this.VIDEO_NAME = { | 23 | this.VIDEO_NAME = { |
25 | VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(120) ], | 24 | VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(120) ], |
26 | MESSAGES: { | 25 | MESSAGES: { |
27 | 'required': this.i18n('Video name is required.'), | 26 | 'required': $localize`Video name is required.`, |
28 | 'minlength': this.i18n('Video name must be at least 3 characters long.'), | 27 | 'minlength': $localize`Video name must be at least 3 characters long.`, |
29 | 'maxlength': this.i18n('Video name cannot be more than 120 characters long.') | 28 | 'maxlength': $localize`Video name cannot be more than 120 characters long.` |
30 | } | 29 | } |
31 | } | 30 | } |
32 | 31 | ||
33 | this.VIDEO_PRIVACY = { | 32 | this.VIDEO_PRIVACY = { |
34 | VALIDATORS: [ Validators.required ], | 33 | VALIDATORS: [ Validators.required ], |
35 | MESSAGES: { | 34 | MESSAGES: { |
36 | 'required': this.i18n('Video privacy is required.') | 35 | 'required': $localize`Video privacy is required.` |
37 | } | 36 | } |
38 | } | 37 | } |
39 | 38 | ||
@@ -60,46 +59,46 @@ export class VideoValidatorsService { | |||
60 | this.VIDEO_CHANNEL = { | 59 | this.VIDEO_CHANNEL = { |
61 | VALIDATORS: [ Validators.required ], | 60 | VALIDATORS: [ Validators.required ], |
62 | MESSAGES: { | 61 | MESSAGES: { |
63 | 'required': this.i18n('Video channel is required.') | 62 | 'required': $localize`Video channel is required.` |
64 | } | 63 | } |
65 | } | 64 | } |
66 | 65 | ||
67 | this.VIDEO_DESCRIPTION = { | 66 | this.VIDEO_DESCRIPTION = { |
68 | VALIDATORS: [ Validators.minLength(3), Validators.maxLength(10000) ], | 67 | VALIDATORS: [ Validators.minLength(3), Validators.maxLength(10000) ], |
69 | MESSAGES: { | 68 | MESSAGES: { |
70 | 'minlength': this.i18n('Video description must be at least 3 characters long.'), | 69 | 'minlength': $localize`Video description must be at least 3 characters long.`, |
71 | 'maxlength': this.i18n('Video description cannot be more than 10000 characters long.') | 70 | 'maxlength': $localize`Video description cannot be more than 10000 characters long.` |
72 | } | 71 | } |
73 | } | 72 | } |
74 | 73 | ||
75 | this.VIDEO_TAG = { | 74 | this.VIDEO_TAG = { |
76 | VALIDATORS: [ Validators.minLength(2), Validators.maxLength(30) ], | 75 | VALIDATORS: [ Validators.minLength(2), Validators.maxLength(30) ], |
77 | MESSAGES: { | 76 | MESSAGES: { |
78 | 'minlength': this.i18n('A tag should be more than 2 characters long.'), | 77 | 'minlength': $localize`A tag should be more than 2 characters long.`, |
79 | 'maxlength': this.i18n('A tag should be less than 30 characters long.') | 78 | 'maxlength': $localize`A tag should be less than 30 characters long.` |
80 | } | 79 | } |
81 | } | 80 | } |
82 | 81 | ||
83 | this.VIDEO_TAGS_ARRAY = { | 82 | this.VIDEO_TAGS_ARRAY = { |
84 | VALIDATORS: [ Validators.maxLength(5), this.arrayTagLengthValidator() ], | 83 | VALIDATORS: [ Validators.maxLength(5), this.arrayTagLengthValidator() ], |
85 | MESSAGES: { | 84 | MESSAGES: { |
86 | 'maxlength': this.i18n('A maximum of 5 tags can be used on a video.'), | 85 | 'maxlength': $localize`A maximum of 5 tags can be used on a video.`, |
87 | 'arrayTagLength': this.i18n('A tag should be more than 2, and less than 30 characters long.') | 86 | 'arrayTagLength': $localize`A tag should be more than 2, and less than 30 characters long.` |
88 | } | 87 | } |
89 | } | 88 | } |
90 | 89 | ||
91 | this.VIDEO_SUPPORT = { | 90 | this.VIDEO_SUPPORT = { |
92 | VALIDATORS: [ Validators.minLength(3), Validators.maxLength(1000) ], | 91 | VALIDATORS: [ Validators.minLength(3), Validators.maxLength(1000) ], |
93 | MESSAGES: { | 92 | MESSAGES: { |
94 | 'minlength': this.i18n('Video support must be at least 3 characters long.'), | 93 | 'minlength': $localize`Video support must be at least 3 characters long.`, |
95 | 'maxlength': this.i18n('Video support cannot be more than 1000 characters long.') | 94 | 'maxlength': $localize`Video support cannot be more than 1000 characters long.` |
96 | } | 95 | } |
97 | } | 96 | } |
98 | 97 | ||
99 | this.VIDEO_SCHEDULE_PUBLICATION_AT = { | 98 | this.VIDEO_SCHEDULE_PUBLICATION_AT = { |
100 | VALIDATORS: [ ], | 99 | VALIDATORS: [ ], |
101 | MESSAGES: { | 100 | MESSAGES: { |
102 | 'required': this.i18n('A date is required to schedule video update.') | 101 | 'required': $localize`A date is required to schedule video update.` |
103 | } | 102 | } |
104 | } | 103 | } |
105 | 104 | ||