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 | |
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')
19 files changed, 156 insertions, 189 deletions
diff --git a/client/src/app/shared/shared-forms/form-validators/abuse-validators.service.ts b/client/src/app/shared/shared-forms/form-validators/abuse-validators.service.ts index 5f15963f3..56d30d6f9 100644 --- a/client/src/app/shared/shared-forms/form-validators/abuse-validators.service.ts +++ b/client/src/app/shared/shared-forms/form-validators/abuse-validators.service.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
2 | import { Validators } from '@angular/forms' | ||
3 | import { Injectable } from '@angular/core' | 1 | import { Injectable } from '@angular/core' |
2 | import { Validators } from '@angular/forms' | ||
4 | import { BuildFormValidator } from './form-validator.service' | 3 | import { BuildFormValidator } from './form-validator.service' |
5 | 4 | ||
6 | @Injectable() | 5 | @Injectable() |
@@ -9,31 +8,31 @@ export class AbuseValidatorsService { | |||
9 | readonly ABUSE_MODERATION_COMMENT: BuildFormValidator | 8 | readonly ABUSE_MODERATION_COMMENT: BuildFormValidator |
10 | readonly ABUSE_MESSAGE: BuildFormValidator | 9 | readonly ABUSE_MESSAGE: BuildFormValidator |
11 | 10 | ||
12 | constructor (private i18n: I18n) { | 11 | constructor () { |
13 | this.ABUSE_REASON = { | 12 | this.ABUSE_REASON = { |
14 | VALIDATORS: [ Validators.required, Validators.minLength(2), Validators.maxLength(3000) ], | 13 | VALIDATORS: [ Validators.required, Validators.minLength(2), Validators.maxLength(3000) ], |
15 | MESSAGES: { | 14 | MESSAGES: { |
16 | 'required': this.i18n('Report reason is required.'), | 15 | 'required': $localize`Report reason is required.`, |
17 | 'minlength': this.i18n('Report reason must be at least 2 characters long.'), | 16 | 'minlength': $localize`Report reason must be at least 2 characters long.`, |
18 | 'maxlength': this.i18n('Report reason cannot be more than 3000 characters long.') | 17 | 'maxlength': $localize`Report reason cannot be more than 3000 characters long.` |
19 | } | 18 | } |
20 | } | 19 | } |
21 | 20 | ||
22 | this.ABUSE_MODERATION_COMMENT = { | 21 | this.ABUSE_MODERATION_COMMENT = { |
23 | VALIDATORS: [ Validators.required, Validators.minLength(2), Validators.maxLength(3000) ], | 22 | VALIDATORS: [ Validators.required, Validators.minLength(2), Validators.maxLength(3000) ], |
24 | MESSAGES: { | 23 | MESSAGES: { |
25 | 'required': this.i18n('Moderation comment is required.'), | 24 | 'required': $localize`Moderation comment is required.`, |
26 | 'minlength': this.i18n('Moderation comment must be at least 2 characters long.'), | 25 | 'minlength': $localize`Moderation comment must be at least 2 characters long.`, |
27 | 'maxlength': this.i18n('Moderation comment cannot be more than 3000 characters long.') | 26 | 'maxlength': $localize`Moderation comment cannot be more than 3000 characters long.` |
28 | } | 27 | } |
29 | } | 28 | } |
30 | 29 | ||
31 | this.ABUSE_MESSAGE = { | 30 | this.ABUSE_MESSAGE = { |
32 | VALIDATORS: [ Validators.required, Validators.minLength(2), Validators.maxLength(3000) ], | 31 | VALIDATORS: [ Validators.required, Validators.minLength(2), Validators.maxLength(3000) ], |
33 | MESSAGES: { | 32 | MESSAGES: { |
34 | 'required': this.i18n('Abuse message is required.'), | 33 | 'required': $localize`Abuse message is required.`, |
35 | 'minlength': this.i18n('Abuse message must be at least 2 characters long.'), | 34 | 'minlength': $localize`Abuse message must be at least 2 characters long.`, |
36 | 'maxlength': this.i18n('Abuse message cannot be more than 3000 characters long.') | 35 | 'maxlength': $localize`Abuse message cannot be more than 3000 characters long.` |
37 | } | 36 | } |
38 | } | 37 | } |
39 | } | 38 | } |
diff --git a/client/src/app/shared/shared-forms/form-validators/batch-domains-validators.service.ts b/client/src/app/shared/shared-forms/form-validators/batch-domains-validators.service.ts index f270b602b..6c7da833f 100644 --- a/client/src/app/shared/shared-forms/form-validators/batch-domains-validators.service.ts +++ b/client/src/app/shared/shared-forms/form-validators/batch-domains-validators.service.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | import { Injectable } from '@angular/core' | 1 | import { Injectable } from '@angular/core' |
2 | import { ValidatorFn, Validators } from '@angular/forms' | 2 | import { ValidatorFn, Validators } from '@angular/forms' |
3 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
4 | import { BuildFormValidator } from './form-validator.service' | 3 | import { BuildFormValidator } from './form-validator.service' |
5 | import { validateHost } from './host' | 4 | import { validateHost } from './host' |
6 | 5 | ||
@@ -8,13 +7,13 @@ import { validateHost } from './host' | |||
8 | export class BatchDomainsValidatorsService { | 7 | export class BatchDomainsValidatorsService { |
9 | readonly DOMAINS: BuildFormValidator | 8 | readonly DOMAINS: BuildFormValidator |
10 | 9 | ||
11 | constructor (private i18n: I18n) { | 10 | constructor () { |
12 | this.DOMAINS = { | 11 | this.DOMAINS = { |
13 | VALIDATORS: [ Validators.required, this.validDomains, this.isHostsUnique ], | 12 | VALIDATORS: [ Validators.required, this.validDomains, this.isHostsUnique ], |
14 | MESSAGES: { | 13 | MESSAGES: { |
15 | 'required': this.i18n('Domain is required.'), | 14 | 'required': $localize`Domain is required.`, |
16 | 'validDomains': this.i18n('Domains entered are invalid.'), | 15 | 'validDomains': $localize`Domains entered are invalid.`, |
17 | 'uniqueDomains': this.i18n('Domains entered contain duplicates.') | 16 | 'uniqueDomains': $localize`Domains entered contain duplicates.` |
18 | } | 17 | } |
19 | } | 18 | } |
20 | } | 19 | } |
@@ -33,7 +32,7 @@ export class BatchDomainsValidatorsService { | |||
33 | 32 | ||
34 | for (const host of hosts) { | 33 | for (const host of hosts) { |
35 | if (validateHost(host) === false) { | 34 | if (validateHost(host) === false) { |
36 | newHostsErrors.push(this.i18n('{{host}} is not valid', { host })) | 35 | newHostsErrors.push($localize`${host} is not valid`) |
37 | } | 36 | } |
38 | } | 37 | } |
39 | 38 | ||
diff --git a/client/src/app/shared/shared-forms/form-validators/custom-config-validators.service.ts b/client/src/app/shared/shared-forms/form-validators/custom-config-validators.service.ts index c77aba6a1..862ff5470 100644 --- a/client/src/app/shared/shared-forms/form-validators/custom-config-validators.service.ts +++ b/client/src/app/shared/shared-forms/form-validators/custom-config-validators.service.ts | |||
@@ -1,7 +1,6 @@ | |||
1 | import { Injectable } from '@angular/core' | ||
1 | import { Validators } from '@angular/forms' | 2 | import { Validators } from '@angular/forms' |
2 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
3 | import { BuildFormValidator } from './form-validator.service' | 3 | import { BuildFormValidator } from './form-validator.service' |
4 | import { Injectable } from '@angular/core' | ||
5 | 4 | ||
6 | @Injectable() | 5 | @Injectable() |
7 | export class CustomConfigValidatorsService { | 6 | export class CustomConfigValidatorsService { |
@@ -16,82 +15,82 @@ export class CustomConfigValidatorsService { | |||
16 | readonly INDEX_URL: BuildFormValidator | 15 | readonly INDEX_URL: BuildFormValidator |
17 | readonly SEARCH_INDEX_URL: BuildFormValidator | 16 | readonly SEARCH_INDEX_URL: BuildFormValidator |
18 | 17 | ||
19 | constructor (private i18n: I18n) { | 18 | constructor () { |
20 | this.INSTANCE_NAME = { | 19 | this.INSTANCE_NAME = { |
21 | VALIDATORS: [ Validators.required ], | 20 | VALIDATORS: [ Validators.required ], |
22 | MESSAGES: { | 21 | MESSAGES: { |
23 | 'required': this.i18n('Instance name is required.') | 22 | 'required': $localize`Instance name is required.` |
24 | } | 23 | } |
25 | } | 24 | } |
26 | 25 | ||
27 | this.INSTANCE_SHORT_DESCRIPTION = { | 26 | this.INSTANCE_SHORT_DESCRIPTION = { |
28 | VALIDATORS: [ Validators.max(250) ], | 27 | VALIDATORS: [ Validators.max(250) ], |
29 | MESSAGES: { | 28 | MESSAGES: { |
30 | 'max': this.i18n('Short description should not be longer than 250 characters.') | 29 | 'max': $localize`Short description should not be longer than 250 characters.` |
31 | } | 30 | } |
32 | } | 31 | } |
33 | 32 | ||
34 | this.SERVICES_TWITTER_USERNAME = { | 33 | this.SERVICES_TWITTER_USERNAME = { |
35 | VALIDATORS: [ Validators.required ], | 34 | VALIDATORS: [ Validators.required ], |
36 | MESSAGES: { | 35 | MESSAGES: { |
37 | 'required': this.i18n('Twitter username is required.') | 36 | 'required': $localize`Twitter username is required.` |
38 | } | 37 | } |
39 | } | 38 | } |
40 | 39 | ||
41 | this.CACHE_PREVIEWS_SIZE = { | 40 | this.CACHE_PREVIEWS_SIZE = { |
42 | VALIDATORS: [ Validators.required, Validators.min(1), Validators.pattern('[0-9]+') ], | 41 | VALIDATORS: [ Validators.required, Validators.min(1), Validators.pattern('[0-9]+') ], |
43 | MESSAGES: { | 42 | MESSAGES: { |
44 | 'required': this.i18n('Previews cache size is required.'), | 43 | 'required': $localize`Previews cache size is required.`, |
45 | 'min': this.i18n('Previews cache size must be greater than 1.'), | 44 | 'min': $localize`Previews cache size must be greater than 1.`, |
46 | 'pattern': this.i18n('Previews cache size must be a number.') | 45 | 'pattern': $localize`Previews cache size must be a number.` |
47 | } | 46 | } |
48 | } | 47 | } |
49 | 48 | ||
50 | this.CACHE_CAPTIONS_SIZE = { | 49 | this.CACHE_CAPTIONS_SIZE = { |
51 | VALIDATORS: [ Validators.required, Validators.min(1), Validators.pattern('[0-9]+') ], | 50 | VALIDATORS: [ Validators.required, Validators.min(1), Validators.pattern('[0-9]+') ], |
52 | MESSAGES: { | 51 | MESSAGES: { |
53 | 'required': this.i18n('Captions cache size is required.'), | 52 | 'required': $localize`Captions cache size is required.`, |
54 | 'min': this.i18n('Captions cache size must be greater than 1.'), | 53 | 'min': $localize`Captions cache size must be greater than 1.`, |
55 | 'pattern': this.i18n('Captions cache size must be a number.') | 54 | 'pattern': $localize`Captions cache size must be a number.` |
56 | } | 55 | } |
57 | } | 56 | } |
58 | 57 | ||
59 | this.SIGNUP_LIMIT = { | 58 | this.SIGNUP_LIMIT = { |
60 | VALIDATORS: [ Validators.required, Validators.min(-1), Validators.pattern('-?[0-9]+') ], | 59 | VALIDATORS: [ Validators.required, Validators.min(-1), Validators.pattern('-?[0-9]+') ], |
61 | MESSAGES: { | 60 | MESSAGES: { |
62 | 'required': this.i18n('Signup limit is required.'), | 61 | 'required': $localize`Signup limit is required.`, |
63 | 'min': this.i18n('Signup limit must be greater than 1.'), | 62 | 'min': $localize`Signup limit must be greater than 1.`, |
64 | 'pattern': this.i18n('Signup limit must be a number.') | 63 | 'pattern': $localize`Signup limit must be a number.` |
65 | } | 64 | } |
66 | } | 65 | } |
67 | 66 | ||
68 | this.ADMIN_EMAIL = { | 67 | this.ADMIN_EMAIL = { |
69 | VALIDATORS: [ Validators.required, Validators.email ], | 68 | VALIDATORS: [ Validators.required, Validators.email ], |
70 | MESSAGES: { | 69 | MESSAGES: { |
71 | 'required': this.i18n('Admin email is required.'), | 70 | 'required': $localize`Admin email is required.`, |
72 | 'email': this.i18n('Admin email must be valid.') | 71 | 'email': $localize`Admin email must be valid.` |
73 | } | 72 | } |
74 | } | 73 | } |
75 | 74 | ||
76 | this.TRANSCODING_THREADS = { | 75 | this.TRANSCODING_THREADS = { |
77 | VALIDATORS: [ Validators.required, Validators.min(0) ], | 76 | VALIDATORS: [ Validators.required, Validators.min(0) ], |
78 | MESSAGES: { | 77 | MESSAGES: { |
79 | 'required': this.i18n('Transcoding threads is required.'), | 78 | 'required': $localize`Transcoding threads is required.`, |
80 | 'min': this.i18n('Transcoding threads must be greater or equal to 0.') | 79 | 'min': $localize`Transcoding threads must be greater or equal to 0.` |
81 | } | 80 | } |
82 | } | 81 | } |
83 | 82 | ||
84 | this.INDEX_URL = { | 83 | this.INDEX_URL = { |
85 | VALIDATORS: [ Validators.pattern(/^https:\/\//) ], | 84 | VALIDATORS: [ Validators.pattern(/^https:\/\//) ], |
86 | MESSAGES: { | 85 | MESSAGES: { |
87 | 'pattern': this.i18n('Index URL should be a URL') | 86 | 'pattern': $localize`Index URL should be a URL` |
88 | } | 87 | } |
89 | } | 88 | } |
90 | 89 | ||
91 | this.SEARCH_INDEX_URL = { | 90 | this.SEARCH_INDEX_URL = { |
92 | VALIDATORS: [ Validators.pattern(/^https?:\/\//) ], | 91 | VALIDATORS: [ Validators.pattern(/^https?:\/\//) ], |
93 | MESSAGES: { | 92 | MESSAGES: { |
94 | 'pattern': this.i18n('Search index URL should be a URL') | 93 | 'pattern': $localize`Search index URL should be a URL` |
95 | } | 94 | } |
96 | } | 95 | } |
97 | } | 96 | } |
diff --git a/client/src/app/shared/shared-forms/form-validators/instance-validators.service.ts b/client/src/app/shared/shared-forms/form-validators/instance-validators.service.ts index 96a35a48f..3628f0b60 100644 --- a/client/src/app/shared/shared-forms/form-validators/instance-validators.service.ts +++ b/client/src/app/shared/shared-forms/form-validators/instance-validators.service.ts | |||
@@ -1,7 +1,6 @@ | |||
1 | import { I18n } from '@ngx-translate/i18n-polyfill' | 1 | import { Injectable } from '@angular/core' |
2 | import { Validators } from '@angular/forms' | 2 | import { Validators } from '@angular/forms' |
3 | import { BuildFormValidator } from './form-validator.service' | 3 | import { BuildFormValidator } from './form-validator.service' |
4 | import { Injectable } from '@angular/core' | ||
5 | 4 | ||
6 | @Injectable() | 5 | @Injectable() |
7 | export class InstanceValidatorsService { | 6 | export class InstanceValidatorsService { |
@@ -10,13 +9,13 @@ export class InstanceValidatorsService { | |||
10 | readonly SUBJECT: BuildFormValidator | 9 | readonly SUBJECT: BuildFormValidator |
11 | readonly BODY: BuildFormValidator | 10 | readonly BODY: BuildFormValidator |
12 | 11 | ||
13 | constructor (private i18n: I18n) { | 12 | constructor () { |
14 | 13 | ||
15 | this.FROM_EMAIL = { | 14 | this.FROM_EMAIL = { |
16 | VALIDATORS: [ Validators.required, Validators.email ], | 15 | VALIDATORS: [ Validators.required, Validators.email ], |
17 | MESSAGES: { | 16 | MESSAGES: { |
18 | 'required': this.i18n('Email is required.'), | 17 | 'required': $localize`Email is required.`, |
19 | 'email': this.i18n('Email must be valid.') | 18 | 'email': $localize`Email must be valid.` |
20 | } | 19 | } |
21 | } | 20 | } |
22 | 21 | ||
@@ -27,9 +26,9 @@ export class InstanceValidatorsService { | |||
27 | Validators.maxLength(120) | 26 | Validators.maxLength(120) |
28 | ], | 27 | ], |
29 | MESSAGES: { | 28 | MESSAGES: { |
30 | 'required': this.i18n('Your name is required.'), | 29 | 'required': $localize`Your name is required.`, |
31 | 'minlength': this.i18n('Your name must be at least 1 character long.'), | 30 | 'minlength': $localize`Your name must be at least 1 character long.`, |
32 | 'maxlength': this.i18n('Your name cannot be more than 120 characters long.') | 31 | 'maxlength': $localize`Your name cannot be more than 120 characters long.` |
33 | } | 32 | } |
34 | } | 33 | } |
35 | 34 | ||
@@ -40,9 +39,9 @@ export class InstanceValidatorsService { | |||
40 | Validators.maxLength(120) | 39 | Validators.maxLength(120) |
41 | ], | 40 | ], |
42 | MESSAGES: { | 41 | MESSAGES: { |
43 | 'required': this.i18n('A subject is required.'), | 42 | 'required': $localize`A subject is required.`, |
44 | 'minlength': this.i18n('The subject must be at least 1 character long.'), | 43 | 'minlength': $localize`The subject must be at least 1 character long.`, |
45 | 'maxlength': this.i18n('The subject cannot be more than 120 characters long.') | 44 | 'maxlength': $localize`The subject cannot be more than 120 characters long.` |
46 | } | 45 | } |
47 | } | 46 | } |
48 | 47 | ||
@@ -53,9 +52,9 @@ export class InstanceValidatorsService { | |||
53 | Validators.maxLength(5000) | 52 | Validators.maxLength(5000) |
54 | ], | 53 | ], |
55 | MESSAGES: { | 54 | MESSAGES: { |
56 | 'required': this.i18n('A message is required.'), | 55 | 'required': $localize`A message is required.`, |
57 | 'minlength': this.i18n('The message must be at least 3 characters long.'), | 56 | 'minlength': $localize`The message must be at least 3 characters long.`, |
58 | 'maxlength': this.i18n('The message cannot be more than 5000 characters long.') | 57 | 'maxlength': $localize`The message cannot be more than 5000 characters long.` |
59 | } | 58 | } |
60 | } | 59 | } |
61 | } | 60 | } |
diff --git a/client/src/app/shared/shared-forms/form-validators/login-validators.service.ts b/client/src/app/shared/shared-forms/form-validators/login-validators.service.ts index a5837357e..67ea11f20 100644 --- a/client/src/app/shared/shared-forms/form-validators/login-validators.service.ts +++ b/client/src/app/shared/shared-forms/form-validators/login-validators.service.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
2 | import { Validators } from '@angular/forms' | ||
3 | import { Injectable } from '@angular/core' | 1 | import { Injectable } from '@angular/core' |
2 | import { Validators } from '@angular/forms' | ||
4 | import { BuildFormValidator } from './form-validator.service' | 3 | import { BuildFormValidator } from './form-validator.service' |
5 | 4 | ||
6 | @Injectable() | 5 | @Injectable() |
@@ -8,13 +7,13 @@ export class LoginValidatorsService { | |||
8 | readonly LOGIN_USERNAME: BuildFormValidator | 7 | readonly LOGIN_USERNAME: BuildFormValidator |
9 | readonly LOGIN_PASSWORD: BuildFormValidator | 8 | readonly LOGIN_PASSWORD: BuildFormValidator |
10 | 9 | ||
11 | constructor (private i18n: I18n) { | 10 | constructor () { |
12 | this.LOGIN_USERNAME = { | 11 | this.LOGIN_USERNAME = { |
13 | VALIDATORS: [ | 12 | VALIDATORS: [ |
14 | Validators.required | 13 | Validators.required |
15 | ], | 14 | ], |
16 | MESSAGES: { | 15 | MESSAGES: { |
17 | 'required': this.i18n('Username is required.') | 16 | 'required': $localize`Username is required.` |
18 | } | 17 | } |
19 | } | 18 | } |
20 | 19 | ||
@@ -23,7 +22,7 @@ export class LoginValidatorsService { | |||
23 | Validators.required | 22 | Validators.required |
24 | ], | 23 | ], |
25 | MESSAGES: { | 24 | MESSAGES: { |
26 | 'required': this.i18n('Password is required.') | 25 | 'required': $localize`Password is required.` |
27 | } | 26 | } |
28 | } | 27 | } |
29 | } | 28 | } |
diff --git a/client/src/app/shared/shared-forms/form-validators/reset-password-validators.service.ts b/client/src/app/shared/shared-forms/form-validators/reset-password-validators.service.ts index d2085a309..3d0b4dd64 100644 --- a/client/src/app/shared/shared-forms/form-validators/reset-password-validators.service.ts +++ b/client/src/app/shared/shared-forms/form-validators/reset-password-validators.service.ts | |||
@@ -1,19 +1,18 @@ | |||
1 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
2 | import { Validators } from '@angular/forms' | ||
3 | import { Injectable } from '@angular/core' | 1 | import { Injectable } from '@angular/core' |
2 | import { Validators } from '@angular/forms' | ||
4 | import { BuildFormValidator } from './form-validator.service' | 3 | import { BuildFormValidator } from './form-validator.service' |
5 | 4 | ||
6 | @Injectable() | 5 | @Injectable() |
7 | export class ResetPasswordValidatorsService { | 6 | export class ResetPasswordValidatorsService { |
8 | readonly RESET_PASSWORD_CONFIRM: BuildFormValidator | 7 | readonly RESET_PASSWORD_CONFIRM: BuildFormValidator |
9 | 8 | ||
10 | constructor (private i18n: I18n) { | 9 | constructor () { |
11 | this.RESET_PASSWORD_CONFIRM = { | 10 | this.RESET_PASSWORD_CONFIRM = { |
12 | VALIDATORS: [ | 11 | VALIDATORS: [ |
13 | Validators.required | 12 | Validators.required |
14 | ], | 13 | ], |
15 | MESSAGES: { | 14 | MESSAGES: { |
16 | 'required': this.i18n('Confirmation of the password is required.') | 15 | 'required': $localize`Confirmation of the password is required.` |
17 | } | 16 | } |
18 | } | 17 | } |
19 | } | 18 | } |
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 @@ | |||
1 | import { I18n } from '@ngx-translate/i18n-polyfill' | 1 | import { Injectable } from '@angular/core' |
2 | import { Validators } from '@angular/forms' | 2 | import { Validators } from '@angular/forms' |
3 | import { BuildFormValidator } from './form-validator.service' | 3 | import { BuildFormValidator } from './form-validator.service' |
4 | import { Injectable } from '@angular/core' | ||
5 | 4 | ||
6 | @Injectable() | 5 | @Injectable() |
7 | export class UserValidatorsService { | 6 | export 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 | ||
diff --git a/client/src/app/shared/shared-forms/form-validators/video-accept-ownership-validators.service.ts b/client/src/app/shared/shared-forms/form-validators/video-accept-ownership-validators.service.ts index 998d616ec..aed9e9cdd 100644 --- a/client/src/app/shared/shared-forms/form-validators/video-accept-ownership-validators.service.ts +++ b/client/src/app/shared/shared-forms/form-validators/video-accept-ownership-validators.service.ts | |||
@@ -1,17 +1,16 @@ | |||
1 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
2 | import { Validators } from '@angular/forms' | ||
3 | import { Injectable } from '@angular/core' | 1 | import { Injectable } from '@angular/core' |
2 | import { Validators } from '@angular/forms' | ||
4 | import { BuildFormValidator } from './form-validator.service' | 3 | import { BuildFormValidator } from './form-validator.service' |
5 | 4 | ||
6 | @Injectable() | 5 | @Injectable() |
7 | export class VideoAcceptOwnershipValidatorsService { | 6 | export class VideoAcceptOwnershipValidatorsService { |
8 | readonly CHANNEL: BuildFormValidator | 7 | readonly CHANNEL: BuildFormValidator |
9 | 8 | ||
10 | constructor (private i18n: I18n) { | 9 | constructor () { |
11 | this.CHANNEL = { | 10 | this.CHANNEL = { |
12 | VALIDATORS: [ Validators.required ], | 11 | VALIDATORS: [ Validators.required ], |
13 | MESSAGES: { | 12 | MESSAGES: { |
14 | 'required': this.i18n('The channel is required.') | 13 | 'required': $localize`The channel is required.` |
15 | } | 14 | } |
16 | } | 15 | } |
17 | } | 16 | } |
diff --git a/client/src/app/shared/shared-forms/form-validators/video-block-validators.service.ts b/client/src/app/shared/shared-forms/form-validators/video-block-validators.service.ts index ddf0ab5eb..bce1880dc 100644 --- a/client/src/app/shared/shared-forms/form-validators/video-block-validators.service.ts +++ b/client/src/app/shared/shared-forms/form-validators/video-block-validators.service.ts | |||
@@ -1,18 +1,17 @@ | |||
1 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
2 | import { Validators } from '@angular/forms' | ||
3 | import { Injectable } from '@angular/core' | 1 | import { Injectable } from '@angular/core' |
2 | import { Validators } from '@angular/forms' | ||
4 | import { BuildFormValidator } from './form-validator.service' | 3 | import { BuildFormValidator } from './form-validator.service' |
5 | 4 | ||
6 | @Injectable() | 5 | @Injectable() |
7 | export class VideoBlockValidatorsService { | 6 | export class VideoBlockValidatorsService { |
8 | readonly VIDEO_BLOCK_REASON: BuildFormValidator | 7 | readonly VIDEO_BLOCK_REASON: BuildFormValidator |
9 | 8 | ||
10 | constructor (private i18n: I18n) { | 9 | constructor () { |
11 | this.VIDEO_BLOCK_REASON = { | 10 | this.VIDEO_BLOCK_REASON = { |
12 | VALIDATORS: [ Validators.minLength(2), Validators.maxLength(300) ], | 11 | VALIDATORS: [ Validators.minLength(2), Validators.maxLength(300) ], |
13 | MESSAGES: { | 12 | MESSAGES: { |
14 | 'minlength': this.i18n('Block reason must be at least 2 characters long.'), | 13 | 'minlength': $localize`Block reason must be at least 2 characters long.`, |
15 | 'maxlength': this.i18n('Block reason cannot be more than 300 characters long.') | 14 | 'maxlength': $localize`Block reason cannot be more than 300 characters long.` |
16 | } | 15 | } |
17 | } | 16 | } |
18 | } | 17 | } |
diff --git a/client/src/app/shared/shared-forms/form-validators/video-captions-validators.service.ts b/client/src/app/shared/shared-forms/form-validators/video-captions-validators.service.ts index 280d28414..7e90264e5 100644 --- a/client/src/app/shared/shared-forms/form-validators/video-captions-validators.service.ts +++ b/client/src/app/shared/shared-forms/form-validators/video-captions-validators.service.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
2 | import { Validators } from '@angular/forms' | ||
3 | import { Injectable } from '@angular/core' | 1 | import { Injectable } from '@angular/core' |
2 | import { Validators } from '@angular/forms' | ||
4 | import { BuildFormValidator } from './form-validator.service' | 3 | import { BuildFormValidator } from './form-validator.service' |
5 | 4 | ||
6 | @Injectable() | 5 | @Injectable() |
@@ -8,19 +7,19 @@ export class VideoCaptionsValidatorsService { | |||
8 | readonly VIDEO_CAPTION_LANGUAGE: BuildFormValidator | 7 | readonly VIDEO_CAPTION_LANGUAGE: BuildFormValidator |
9 | readonly VIDEO_CAPTION_FILE: BuildFormValidator | 8 | readonly VIDEO_CAPTION_FILE: BuildFormValidator |
10 | 9 | ||
11 | constructor (private i18n: I18n) { | 10 | constructor () { |
12 | 11 | ||
13 | this.VIDEO_CAPTION_LANGUAGE = { | 12 | this.VIDEO_CAPTION_LANGUAGE = { |
14 | VALIDATORS: [ Validators.required ], | 13 | VALIDATORS: [ Validators.required ], |
15 | MESSAGES: { | 14 | MESSAGES: { |
16 | 'required': this.i18n('Video caption language is required.') | 15 | 'required': $localize`Video caption language is required.` |
17 | } | 16 | } |
18 | } | 17 | } |
19 | 18 | ||
20 | this.VIDEO_CAPTION_FILE = { | 19 | this.VIDEO_CAPTION_FILE = { |
21 | VALIDATORS: [ Validators.required ], | 20 | VALIDATORS: [ Validators.required ], |
22 | MESSAGES: { | 21 | MESSAGES: { |
23 | 'required': this.i18n('Video caption file is required.') | 22 | 'required': $localize`Video caption file is required.` |
24 | } | 23 | } |
25 | } | 24 | } |
26 | } | 25 | } |
diff --git a/client/src/app/shared/shared-forms/form-validators/video-change-ownership-validators.service.ts b/client/src/app/shared/shared-forms/form-validators/video-change-ownership-validators.service.ts index 59659defd..8c809a0d5 100644 --- a/client/src/app/shared/shared-forms/form-validators/video-change-ownership-validators.service.ts +++ b/client/src/app/shared/shared-forms/form-validators/video-change-ownership-validators.service.ts | |||
@@ -1,18 +1,17 @@ | |||
1 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
2 | import { AbstractControl, ValidationErrors, Validators } from '@angular/forms' | ||
3 | import { Injectable } from '@angular/core' | 1 | import { Injectable } from '@angular/core' |
2 | import { AbstractControl, ValidationErrors, Validators } from '@angular/forms' | ||
4 | import { BuildFormValidator } from './form-validator.service' | 3 | import { BuildFormValidator } from './form-validator.service' |
5 | 4 | ||
6 | @Injectable() | 5 | @Injectable() |
7 | export class VideoChangeOwnershipValidatorsService { | 6 | export class VideoChangeOwnershipValidatorsService { |
8 | readonly USERNAME: BuildFormValidator | 7 | readonly USERNAME: BuildFormValidator |
9 | 8 | ||
10 | constructor (private i18n: I18n) { | 9 | constructor () { |
11 | this.USERNAME = { | 10 | this.USERNAME = { |
12 | VALIDATORS: [ Validators.required, this.localAccountValidator ], | 11 | VALIDATORS: [ Validators.required, this.localAccountValidator ], |
13 | MESSAGES: { | 12 | MESSAGES: { |
14 | 'required': this.i18n('The username is required.'), | 13 | 'required': $localize`The username is required.`, |
15 | 'localAccountOnly': this.i18n('You can only transfer ownership to a local account') | 14 | 'localAccountOnly': $localize`You can only transfer ownership to a local account` |
16 | } | 15 | } |
17 | } | 16 | } |
18 | } | 17 | } |
diff --git a/client/src/app/shared/shared-forms/form-validators/video-channel-validators.service.ts b/client/src/app/shared/shared-forms/form-validators/video-channel-validators.service.ts index bb650b149..3e7444196 100644 --- a/client/src/app/shared/shared-forms/form-validators/video-channel-validators.service.ts +++ b/client/src/app/shared/shared-forms/form-validators/video-channel-validators.service.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
2 | import { Validators } from '@angular/forms' | ||
3 | import { Injectable } from '@angular/core' | 1 | import { Injectable } from '@angular/core' |
2 | import { Validators } from '@angular/forms' | ||
4 | import { BuildFormValidator } from './form-validator.service' | 3 | import { BuildFormValidator } from './form-validator.service' |
5 | 4 | ||
6 | @Injectable() | 5 | @Injectable() |
@@ -10,7 +9,7 @@ export class VideoChannelValidatorsService { | |||
10 | readonly VIDEO_CHANNEL_DESCRIPTION: BuildFormValidator | 9 | readonly VIDEO_CHANNEL_DESCRIPTION: BuildFormValidator |
11 | readonly VIDEO_CHANNEL_SUPPORT: BuildFormValidator | 10 | readonly VIDEO_CHANNEL_SUPPORT: BuildFormValidator |
12 | 11 | ||
13 | constructor (private i18n: I18n) { | 12 | constructor () { |
14 | this.VIDEO_CHANNEL_NAME = { | 13 | this.VIDEO_CHANNEL_NAME = { |
15 | VALIDATORS: [ | 14 | VALIDATORS: [ |
16 | Validators.required, | 15 | Validators.required, |
@@ -19,10 +18,10 @@ export class VideoChannelValidatorsService { | |||
19 | Validators.pattern(/^[a-z0-9][a-z0-9._]*$/) | 18 | Validators.pattern(/^[a-z0-9][a-z0-9._]*$/) |
20 | ], | 19 | ], |
21 | MESSAGES: { | 20 | MESSAGES: { |
22 | 'required': this.i18n('Name is required.'), | 21 | 'required': $localize`Name is required.`, |
23 | 'minlength': this.i18n('Name must be at least 1 character long.'), | 22 | 'minlength': $localize`Name must be at least 1 character long.`, |
24 | 'maxlength': this.i18n('Name cannot be more than 50 characters long.'), | 23 | 'maxlength': $localize`Name cannot be more than 50 characters long.`, |
25 | 'pattern': this.i18n('Name should be lowercase alphanumeric; dots and underscores are allowed.') | 24 | 'pattern': $localize`Name should be lowercase alphanumeric; dots and underscores are allowed.` |
26 | } | 25 | } |
27 | } | 26 | } |
28 | 27 | ||
@@ -33,9 +32,9 @@ export class VideoChannelValidatorsService { | |||
33 | Validators.maxLength(50) | 32 | Validators.maxLength(50) |
34 | ], | 33 | ], |
35 | MESSAGES: { | 34 | MESSAGES: { |
36 | 'required': i18n('Display name is required.'), | 35 | 'required': $localize`Display name is required.`, |
37 | 'minlength': i18n('Display name must be at least 1 character long.'), | 36 | 'minlength': $localize`Display name must be at least 1 character long.`, |
38 | 'maxlength': i18n('Display name cannot be more than 50 characters long.') | 37 | 'maxlength': $localize`Display name cannot be more than 50 characters long.` |
39 | } | 38 | } |
40 | } | 39 | } |
41 | 40 | ||
@@ -45,8 +44,8 @@ export class VideoChannelValidatorsService { | |||
45 | Validators.maxLength(1000) | 44 | Validators.maxLength(1000) |
46 | ], | 45 | ], |
47 | MESSAGES: { | 46 | MESSAGES: { |
48 | 'minlength': i18n('Description must be at least 3 characters long.'), | 47 | 'minlength': $localize`Description must be at least 3 characters long.`, |
49 | 'maxlength': i18n('Description cannot be more than 1000 characters long.') | 48 | 'maxlength': $localize`Description cannot be more than 1000 characters long.` |
50 | } | 49 | } |
51 | } | 50 | } |
52 | 51 | ||
@@ -56,8 +55,8 @@ export class VideoChannelValidatorsService { | |||
56 | Validators.maxLength(1000) | 55 | Validators.maxLength(1000) |
57 | ], | 56 | ], |
58 | MESSAGES: { | 57 | MESSAGES: { |
59 | 'minlength': i18n('Support text must be at least 3 characters long.'), | 58 | 'minlength': $localize`Support text must be at least 3 characters long.`, |
60 | 'maxlength': i18n('Support text cannot be more than 1000 characters long.') | 59 | 'maxlength': $localize`Support text cannot be more than 1000 characters long` |
61 | } | 60 | } |
62 | } | 61 | } |
63 | } | 62 | } |
diff --git a/client/src/app/shared/shared-forms/form-validators/video-comment-validators.service.ts b/client/src/app/shared/shared-forms/form-validators/video-comment-validators.service.ts index 97c8e967e..18e7ae264 100644 --- a/client/src/app/shared/shared-forms/form-validators/video-comment-validators.service.ts +++ b/client/src/app/shared/shared-forms/form-validators/video-comment-validators.service.ts | |||
@@ -1,19 +1,18 @@ | |||
1 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
2 | import { Validators } from '@angular/forms' | ||
3 | import { Injectable } from '@angular/core' | 1 | import { Injectable } from '@angular/core' |
2 | import { Validators } from '@angular/forms' | ||
4 | import { BuildFormValidator } from './form-validator.service' | 3 | import { BuildFormValidator } from './form-validator.service' |
5 | 4 | ||
6 | @Injectable() | 5 | @Injectable() |
7 | export class VideoCommentValidatorsService { | 6 | export class VideoCommentValidatorsService { |
8 | readonly VIDEO_COMMENT_TEXT: BuildFormValidator | 7 | readonly VIDEO_COMMENT_TEXT: BuildFormValidator |
9 | 8 | ||
10 | constructor (private i18n: I18n) { | 9 | constructor () { |
11 | this.VIDEO_COMMENT_TEXT = { | 10 | this.VIDEO_COMMENT_TEXT = { |
12 | VALIDATORS: [ Validators.required, Validators.minLength(1), Validators.maxLength(3000) ], | 11 | VALIDATORS: [ Validators.required, Validators.minLength(1), Validators.maxLength(3000) ], |
13 | MESSAGES: { | 12 | MESSAGES: { |
14 | 'required': this.i18n('Comment is required.'), | 13 | 'required': $localize`Comment is required.`, |
15 | 'minlength': this.i18n('Comment must be at least 2 characters long.'), | 14 | 'minlength': $localize`Comment must be at least 2 characters long.`, |
16 | 'maxlength': this.i18n('Comment cannot be more than 3000 characters long.') | 15 | 'maxlength': $localize`Comment cannot be more than 3000 characters long.` |
17 | } | 16 | } |
18 | } | 17 | } |
19 | } | 18 | } |
diff --git a/client/src/app/shared/shared-forms/form-validators/video-playlist-validators.service.ts b/client/src/app/shared/shared-forms/form-validators/video-playlist-validators.service.ts index ab9c43625..3b45a40fd 100644 --- a/client/src/app/shared/shared-forms/form-validators/video-playlist-validators.service.ts +++ b/client/src/app/shared/shared-forms/form-validators/video-playlist-validators.service.ts | |||
@@ -1,8 +1,7 @@ | |||
1 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
2 | import { AbstractControl, FormControl, Validators } from '@angular/forms' | ||
3 | import { Injectable } from '@angular/core' | 1 | import { Injectable } from '@angular/core' |
4 | import { BuildFormValidator } from './form-validator.service' | 2 | import { AbstractControl, Validators } from '@angular/forms' |
5 | import { VideoPlaylistPrivacy } from '@shared/models' | 3 | import { VideoPlaylistPrivacy } from '@shared/models' |
4 | import { BuildFormValidator } from './form-validator.service' | ||
6 | 5 | ||
7 | @Injectable() | 6 | @Injectable() |
8 | export class VideoPlaylistValidatorsService { | 7 | export class VideoPlaylistValidatorsService { |
@@ -11,7 +10,7 @@ export class VideoPlaylistValidatorsService { | |||
11 | readonly VIDEO_PLAYLIST_DESCRIPTION: BuildFormValidator | 10 | readonly VIDEO_PLAYLIST_DESCRIPTION: BuildFormValidator |
12 | readonly VIDEO_PLAYLIST_CHANNEL_ID: BuildFormValidator | 11 | readonly VIDEO_PLAYLIST_CHANNEL_ID: BuildFormValidator |
13 | 12 | ||
14 | constructor (private i18n: I18n) { | 13 | constructor () { |
15 | this.VIDEO_PLAYLIST_DISPLAY_NAME = { | 14 | this.VIDEO_PLAYLIST_DISPLAY_NAME = { |
16 | VALIDATORS: [ | 15 | VALIDATORS: [ |
17 | Validators.required, | 16 | Validators.required, |
@@ -19,9 +18,9 @@ export class VideoPlaylistValidatorsService { | |||
19 | Validators.maxLength(120) | 18 | Validators.maxLength(120) |
20 | ], | 19 | ], |
21 | MESSAGES: { | 20 | MESSAGES: { |
22 | 'required': this.i18n('Display name is required.'), | 21 | 'required': $localize`Display name is required.`, |
23 | 'minlength': this.i18n('Display name must be at least 1 character long.'), | 22 | 'minlength': $localize`Display name must be at least 1 character long.`, |
24 | 'maxlength': this.i18n('Display name cannot be more than 120 characters long.') | 23 | 'maxlength': $localize`Display name cannot be more than 120 characters long.` |
25 | } | 24 | } |
26 | } | 25 | } |
27 | 26 | ||
@@ -30,7 +29,7 @@ export class VideoPlaylistValidatorsService { | |||
30 | Validators.required | 29 | Validators.required |
31 | ], | 30 | ], |
32 | MESSAGES: { | 31 | MESSAGES: { |
33 | 'required': this.i18n('Privacy is required.') | 32 | 'required': $localize`Privacy is required.` |
34 | } | 33 | } |
35 | } | 34 | } |
36 | 35 | ||
@@ -40,15 +39,15 @@ export class VideoPlaylistValidatorsService { | |||
40 | Validators.maxLength(1000) | 39 | Validators.maxLength(1000) |
41 | ], | 40 | ], |
42 | MESSAGES: { | 41 | MESSAGES: { |
43 | 'minlength': i18n('Description must be at least 3 characters long.'), | 42 | 'minlength': $localize`Description must be at least 3 characters long.`, |
44 | 'maxlength': i18n('Description cannot be more than 1000 characters long.') | 43 | 'maxlength': $localize`Description cannot be more than 1000 characters long.` |
45 | } | 44 | } |
46 | } | 45 | } |
47 | 46 | ||
48 | this.VIDEO_PLAYLIST_CHANNEL_ID = { | 47 | this.VIDEO_PLAYLIST_CHANNEL_ID = { |
49 | VALIDATORS: [ ], | 48 | VALIDATORS: [ ], |
50 | MESSAGES: { | 49 | MESSAGES: { |
51 | 'required': this.i18n('The channel is required when the playlist is public.') | 50 | 'required': $localize`The channel is required when the playlist is public.` |
52 | } | 51 | } |
53 | } | 52 | } |
54 | } | 53 | } |
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 | ||
diff --git a/client/src/app/shared/shared-forms/input-readonly-copy.component.ts b/client/src/app/shared/shared-forms/input-readonly-copy.component.ts index 7528fb7a1..a67b0c691 100644 --- a/client/src/app/shared/shared-forms/input-readonly-copy.component.ts +++ b/client/src/app/shared/shared-forms/input-readonly-copy.component.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | import { Component, Input } from '@angular/core' | 1 | import { Component, Input } from '@angular/core' |
2 | import { Notifier } from '@app/core' | 2 | import { Notifier } from '@app/core' |
3 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
4 | 3 | ||
5 | @Component({ | 4 | @Component({ |
6 | selector: 'my-input-readonly-copy', | 5 | selector: 'my-input-readonly-copy', |
@@ -10,12 +9,9 @@ import { I18n } from '@ngx-translate/i18n-polyfill' | |||
10 | export class InputReadonlyCopyComponent { | 9 | export class InputReadonlyCopyComponent { |
11 | @Input() value = '' | 10 | @Input() value = '' |
12 | 11 | ||
13 | constructor ( | 12 | constructor (private notifier: Notifier) { } |
14 | private notifier: Notifier, | ||
15 | private i18n: I18n | ||
16 | ) { } | ||
17 | 13 | ||
18 | activateCopiedMessage () { | 14 | activateCopiedMessage () { |
19 | this.notifier.success(this.i18n('Copied')) | 15 | this.notifier.success($localize`Copied`) |
20 | } | 16 | } |
21 | } | 17 | } |
diff --git a/client/src/app/shared/shared-forms/preview-upload.component.ts b/client/src/app/shared/shared-forms/preview-upload.component.ts index 7afff0b31..a55dcdd9a 100644 --- a/client/src/app/shared/shared-forms/preview-upload.component.ts +++ b/client/src/app/shared/shared-forms/preview-upload.component.ts | |||
@@ -2,7 +2,6 @@ import { Component, forwardRef, Input, OnInit } from '@angular/core' | |||
2 | import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' | 2 | import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' |
3 | import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser' | 3 | import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser' |
4 | import { ServerService } from '@app/core' | 4 | import { ServerService } from '@app/core' |
5 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
6 | import { ServerConfig } from '@shared/models' | 5 | import { ServerConfig } from '@shared/models' |
7 | import { BytesPipe } from '../shared-main' | 6 | import { BytesPipe } from '../shared-main' |
8 | 7 | ||
@@ -34,11 +33,10 @@ export class PreviewUploadComponent implements OnInit, ControlValueAccessor { | |||
34 | 33 | ||
35 | constructor ( | 34 | constructor ( |
36 | private sanitizer: DomSanitizer, | 35 | private sanitizer: DomSanitizer, |
37 | private serverService: ServerService, | 36 | private serverService: ServerService |
38 | private i18n: I18n | ||
39 | ) { | 37 | ) { |
40 | this.bytesPipe = new BytesPipe() | 38 | this.bytesPipe = new BytesPipe() |
41 | this.maxSizeText = this.i18n('max size') | 39 | this.maxSizeText = $localize`max size` |
42 | } | 40 | } |
43 | 41 | ||
44 | get videoImageExtensions () { | 42 | get videoImageExtensions () { |
diff --git a/client/src/app/shared/shared-forms/reactive-file.component.ts b/client/src/app/shared/shared-forms/reactive-file.component.ts index 9ebf487ce..eeb2a3fd8 100644 --- a/client/src/app/shared/shared-forms/reactive-file.component.ts +++ b/client/src/app/shared/shared-forms/reactive-file.component.ts | |||
@@ -2,7 +2,6 @@ import { Component, EventEmitter, forwardRef, Input, OnInit, Output } from '@ang | |||
2 | import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' | 2 | import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' |
3 | import { Notifier } from '@app/core' | 3 | import { Notifier } from '@app/core' |
4 | import { GlobalIconName } from '@app/shared/shared-icons' | 4 | import { GlobalIconName } from '@app/shared/shared-icons' |
5 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
6 | 5 | ||
7 | @Component({ | 6 | @Component({ |
8 | selector: 'my-reactive-file', | 7 | selector: 'my-reactive-file', |
@@ -31,10 +30,7 @@ export class ReactiveFileComponent implements OnInit, ControlValueAccessor { | |||
31 | 30 | ||
32 | private file: File | 31 | private file: File |
33 | 32 | ||
34 | constructor ( | 33 | constructor (private notifier: Notifier) { } |
35 | private notifier: Notifier, | ||
36 | private i18n: I18n | ||
37 | ) {} | ||
38 | 34 | ||
39 | get filename () { | 35 | get filename () { |
40 | if (!this.file) return '' | 36 | if (!this.file) return '' |
@@ -51,16 +47,13 @@ export class ReactiveFileComponent implements OnInit, ControlValueAccessor { | |||
51 | const [ file ] = event.target.files | 47 | const [ file ] = event.target.files |
52 | 48 | ||
53 | if (file.size > this.maxFileSize) { | 49 | if (file.size > this.maxFileSize) { |
54 | this.notifier.error(this.i18n('This file is too large.')) | 50 | this.notifier.error($localize`This file is too large.`) |
55 | return | 51 | return |
56 | } | 52 | } |
57 | 53 | ||
58 | const extension = '.' + file.name.split('.').pop() | 54 | const extension = '.' + file.name.split('.').pop() |
59 | if (this.extensions.includes(extension) === false) { | 55 | if (this.extensions.includes(extension) === false) { |
60 | const message = this.i18n( | 56 | const message = $localize`PeerTube cannot handle this kind of file. Accepted extensions are ${this.allowedExtensionsMessage}}.` |
61 | 'PeerTube cannot handle this kind of file. Accepted extensions are {{extensions}}.', | ||
62 | { extensions: this.allowedExtensionsMessage } | ||
63 | ) | ||
64 | this.notifier.error(message) | 57 | this.notifier.error(message) |
65 | 58 | ||
66 | return | 59 | return |
diff --git a/client/src/app/shared/shared-forms/select/select-checkbox.component.ts b/client/src/app/shared/shared-forms/select/select-checkbox.component.ts index fd683ae5d..eb0c49034 100644 --- a/client/src/app/shared/shared-forms/select/select-checkbox.component.ts +++ b/client/src/app/shared/shared-forms/select/select-checkbox.component.ts | |||
@@ -1,7 +1,6 @@ | |||
1 | import { Component, Input, forwardRef, OnInit } from '@angular/core' | 1 | import { Component, forwardRef, Input, OnInit } from '@angular/core' |
2 | import { NG_VALUE_ACCESSOR, ControlValueAccessor } from '@angular/forms' | 2 | import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' |
3 | import { SelectOptionsItem } from './select-options.component' | 3 | import { SelectOptionsItem } from './select-options.component' |
4 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
5 | 4 | ||
6 | export type ItemSelectCheckboxValue = { id?: string | number, group?: string } | string | 5 | export type ItemSelectCheckboxValue = { id?: string | number, group?: string } | string |
7 | 6 | ||
@@ -25,12 +24,8 @@ export class SelectCheckboxComponent implements OnInit, ControlValueAccessor { | |||
25 | @Input() maxSelectedItems: number | 24 | @Input() maxSelectedItems: number |
26 | @Input() placeholder: string | 25 | @Input() placeholder: string |
27 | 26 | ||
28 | constructor ( | ||
29 | private i18n: I18n | ||
30 | ) {} | ||
31 | |||
32 | ngOnInit () { | 27 | ngOnInit () { |
33 | if (!this.placeholder) this.placeholder = this.i18n('Add a new option') | 28 | if (!this.placeholder) this.placeholder = $localize`Add a new option` |
34 | } | 29 | } |
35 | 30 | ||
36 | propagateChange = (_: any) => { /* empty */ } | 31 | propagateChange = (_: any) => { /* empty */ } |