aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-forms/form-validators/user-validators.service.ts
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/shared/shared-forms/form-validators/user-validators.service.ts
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/shared/shared-forms/form-validators/user-validators.service.ts')
-rw-r--r--client/src/app/shared/shared-forms/form-validators/user-validators.service.ts63
1 files changed, 31 insertions, 32 deletions
diff --git a/client/src/app/shared/shared-forms/form-validators/user-validators.service.ts b/client/src/app/shared/shared-forms/form-validators/user-validators.service.ts
index 61486bbab..312fc9b1e 100644
--- a/client/src/app/shared/shared-forms/form-validators/user-validators.service.ts
+++ b/client/src/app/shared/shared-forms/form-validators/user-validators.service.ts
@@ -1,7 +1,6 @@
1import { I18n } from '@ngx-translate/i18n-polyfill' 1import { Injectable } from '@angular/core'
2import { Validators } from '@angular/forms' 2import { Validators } from '@angular/forms'
3import { BuildFormValidator } from './form-validator.service' 3import { BuildFormValidator } from './form-validator.service'
4import { Injectable } from '@angular/core'
5 4
6@Injectable() 5@Injectable()
7export class UserValidatorsService { 6export class UserValidatorsService {
@@ -20,7 +19,7 @@ export class UserValidatorsService {
20 19
21 readonly USER_BAN_REASON: BuildFormValidator 20 readonly USER_BAN_REASON: BuildFormValidator
22 21
23 constructor (private i18n: I18n) { 22 constructor () {
24 23
25 this.USER_USERNAME = { 24 this.USER_USERNAME = {
26 VALIDATORS: [ 25 VALIDATORS: [
@@ -30,10 +29,10 @@ export class UserValidatorsService {
30 Validators.pattern(/^[a-z0-9][a-z0-9._]*$/) 29 Validators.pattern(/^[a-z0-9][a-z0-9._]*$/)
31 ], 30 ],
32 MESSAGES: { 31 MESSAGES: {
33 'required': this.i18n('Username is required.'), 32 'required': $localize`Username is required.`,
34 'minlength': this.i18n('Username must be at least 1 character long.'), 33 'minlength': $localize`Username must be at least 1 character long.`,
35 'maxlength': this.i18n('Username cannot be more than 50 characters long.'), 34 'maxlength': $localize`Username cannot be more than 50 characters long.`,
36 'pattern': this.i18n('Username should be lowercase alphanumeric; dots and underscores are allowed.') 35 'pattern': $localize`Username should be lowercase alphanumeric; dots and underscores are allowed.`
37 } 36 }
38 } 37 }
39 38
@@ -45,18 +44,18 @@ export class UserValidatorsService {
45 Validators.pattern(/^[a-z0-9][a-z0-9._]*$/) 44 Validators.pattern(/^[a-z0-9][a-z0-9._]*$/)
46 ], 45 ],
47 MESSAGES: { 46 MESSAGES: {
48 'required': this.i18n('Channel name is required.'), 47 'required': $localize`Channel name is required.`,
49 'minlength': this.i18n('Channel name must be at least 1 character long.'), 48 'minlength': $localize`Channel name must be at least 1 character long.`,
50 'maxlength': this.i18n('Channel name cannot be more than 50 characters long.'), 49 'maxlength': $localize`Channel name cannot be more than 50 characters long.`,
51 'pattern': this.i18n('Channel name should be lowercase alphanumeric; dots and underscores are allowed.') 50 'pattern': $localize`Channel name should be lowercase alphanumeric; dots and underscores are allowed.`
52 } 51 }
53 } 52 }
54 53
55 this.USER_EMAIL = { 54 this.USER_EMAIL = {
56 VALIDATORS: [ Validators.required, Validators.email ], 55 VALIDATORS: [ Validators.required, Validators.email ],
57 MESSAGES: { 56 MESSAGES: {
58 'required': this.i18n('Email is required.'), 57 'required': $localize`Email is required.`,
59 'email': this.i18n('Email must be valid.') 58 'email': $localize`Email must be valid.`
60 } 59 }
61 } 60 }
62 61
@@ -67,9 +66,9 @@ export class UserValidatorsService {
67 Validators.maxLength(255) 66 Validators.maxLength(255)
68 ], 67 ],
69 MESSAGES: { 68 MESSAGES: {
70 'required': this.i18n('Password is required.'), 69 'required': $localize`Password is required.`,
71 'minlength': this.i18n('Password must be at least 6 characters long.'), 70 'minlength': $localize`Password must be at least 6 characters long.`,
72 'maxlength': this.i18n('Password cannot be more than 255 characters long.') 71 'maxlength': $localize`Password cannot be more than 255 characters long.`
73 } 72 }
74 } 73 }
75 74
@@ -79,37 +78,37 @@ export class UserValidatorsService {
79 Validators.maxLength(255) 78 Validators.maxLength(255)
80 ], 79 ],
81 MESSAGES: { 80 MESSAGES: {
82 'minlength': this.i18n('Password must be at least 6 characters long.'), 81 'minlength': $localize`Password must be at least 6 characters long.`,
83 'maxlength': this.i18n('Password cannot be more than 255 characters long.') 82 'maxlength': $localize`Password cannot be more than 255 characters long.`
84 } 83 }
85 } 84 }
86 85
87 this.USER_CONFIRM_PASSWORD = { 86 this.USER_CONFIRM_PASSWORD = {
88 VALIDATORS: [], 87 VALIDATORS: [],
89 MESSAGES: { 88 MESSAGES: {
90 'matchPassword': this.i18n('The new password and the confirmed password do not correspond.') 89 'matchPassword': $localize`The new password and the confirmed password do not correspond.`
91 } 90 }
92 } 91 }
93 92
94 this.USER_VIDEO_QUOTA = { 93 this.USER_VIDEO_QUOTA = {
95 VALIDATORS: [ Validators.required, Validators.min(-1) ], 94 VALIDATORS: [ Validators.required, Validators.min(-1) ],
96 MESSAGES: { 95 MESSAGES: {
97 'required': this.i18n('Video quota is required.'), 96 'required': $localize`Video quota is required.`,
98 'min': this.i18n('Quota must be greater than -1.') 97 'min': $localize`Quota must be greater than -1.`
99 } 98 }
100 } 99 }
101 this.USER_VIDEO_QUOTA_DAILY = { 100 this.USER_VIDEO_QUOTA_DAILY = {
102 VALIDATORS: [ Validators.required, Validators.min(-1) ], 101 VALIDATORS: [ Validators.required, Validators.min(-1) ],
103 MESSAGES: { 102 MESSAGES: {
104 'required': this.i18n('Daily upload limit is required.'), 103 'required': $localize`Daily upload limit is required.`,
105 'min': this.i18n('Daily upload limit must be greater than -1.') 104 'min': $localize`Daily upload limit must be greater than -1.`
106 } 105 }
107 } 106 }
108 107
109 this.USER_ROLE = { 108 this.USER_ROLE = {
110 VALIDATORS: [ Validators.required ], 109 VALIDATORS: [ Validators.required ],
111 MESSAGES: { 110 MESSAGES: {
112 'required': this.i18n('User role is required.') 111 'required': $localize`User role is required.`
113 } 112 }
114 } 113 }
115 114
@@ -121,8 +120,8 @@ export class UserValidatorsService {
121 Validators.maxLength(1000) 120 Validators.maxLength(1000)
122 ], 121 ],
123 MESSAGES: { 122 MESSAGES: {
124 'minlength': this.i18n('Description must be at least 3 characters long.'), 123 'minlength': $localize`Description must be at least 3 characters long.`,
125 'maxlength': this.i18n('Description cannot be more than 1000 characters long.') 124 'maxlength': $localize`Description cannot be more than 1000 characters long.`
126 } 125 }
127 } 126 }
128 127
@@ -131,7 +130,7 @@ export class UserValidatorsService {
131 Validators.requiredTrue 130 Validators.requiredTrue
132 ], 131 ],
133 MESSAGES: { 132 MESSAGES: {
134 'required': this.i18n('You must agree with the instance terms in order to register on it.') 133 'required': $localize`You must agree with the instance terms in order to register on it.`
135 } 134 }
136 } 135 }
137 136
@@ -141,8 +140,8 @@ export class UserValidatorsService {
141 Validators.maxLength(250) 140 Validators.maxLength(250)
142 ], 141 ],
143 MESSAGES: { 142 MESSAGES: {
144 'minlength': this.i18n('Ban reason must be at least 3 characters long.'), 143 'minlength': $localize`Ban reason must be at least 3 characters long.`,
145 'maxlength': this.i18n('Ban reason cannot be more than 250 characters long.') 144 'maxlength': $localize`Ban reason cannot be more than 250 characters long.`
146 } 145 }
147 } 146 }
148 } 147 }
@@ -154,9 +153,9 @@ export class UserValidatorsService {
154 Validators.maxLength(120) 153 Validators.maxLength(120)
155 ], 154 ],
156 MESSAGES: { 155 MESSAGES: {
157 'required': this.i18n('Display name is required.'), 156 'required': $localize`Display name is required.`,
158 'minlength': this.i18n('Display name must be at least 1 character long.'), 157 'minlength': $localize`Display name must be at least 1 character long.`,
159 'maxlength': this.i18n('Display name cannot be more than 50 characters long.') 158 'maxlength': $localize`Display name cannot be more than 50 characters long.`
160 } 159 }
161 } 160 }
162 161