]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/shared-forms/form-validators/custom-config-validators.service.ts
Migrate to $localize
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-forms / form-validators / custom-config-validators.service.ts
index c77aba6a1050c5e43be2e066a001d44b2ffa236d..862ff54709662f14b4e2c9880b328b4967b9346e 100644 (file)
@@ -1,7 +1,6 @@
+import { Injectable } from '@angular/core'
 import { Validators } from '@angular/forms'
-import { I18n } from '@ngx-translate/i18n-polyfill'
 import { BuildFormValidator } from './form-validator.service'
-import { Injectable } from '@angular/core'
 
 @Injectable()
 export class CustomConfigValidatorsService {
@@ -16,82 +15,82 @@ export class CustomConfigValidatorsService {
   readonly INDEX_URL: BuildFormValidator
   readonly SEARCH_INDEX_URL: BuildFormValidator
 
-  constructor (private i18n: I18n) {
+  constructor () {
     this.INSTANCE_NAME = {
       VALIDATORS: [ Validators.required ],
       MESSAGES: {
-        'required': this.i18n('Instance name is required.')
+        'required': $localize`Instance name is required.`
       }
     }
 
     this.INSTANCE_SHORT_DESCRIPTION = {
       VALIDATORS: [ Validators.max(250) ],
       MESSAGES: {
-        'max': this.i18n('Short description should not be longer than 250 characters.')
+        'max': $localize`Short description should not be longer than 250 characters.`
       }
     }
 
     this.SERVICES_TWITTER_USERNAME = {
       VALIDATORS: [ Validators.required ],
       MESSAGES: {
-        'required': this.i18n('Twitter username is required.')
+        'required': $localize`Twitter username is required.`
       }
     }
 
     this.CACHE_PREVIEWS_SIZE = {
       VALIDATORS: [ Validators.required, Validators.min(1), Validators.pattern('[0-9]+') ],
       MESSAGES: {
-        'required': this.i18n('Previews cache size is required.'),
-        'min': this.i18n('Previews cache size must be greater than 1.'),
-        'pattern': this.i18n('Previews cache size must be a number.')
+        'required': $localize`Previews cache size is required.`,
+        'min': $localize`Previews cache size must be greater than 1.`,
+        'pattern': $localize`Previews cache size must be a number.`
       }
     }
 
     this.CACHE_CAPTIONS_SIZE = {
       VALIDATORS: [ Validators.required, Validators.min(1), Validators.pattern('[0-9]+') ],
       MESSAGES: {
-        'required': this.i18n('Captions cache size is required.'),
-        'min': this.i18n('Captions cache size must be greater than 1.'),
-        'pattern': this.i18n('Captions cache size must be a number.')
+        'required': $localize`Captions cache size is required.`,
+        'min': $localize`Captions cache size must be greater than 1.`,
+        'pattern': $localize`Captions cache size must be a number.`
       }
     }
 
     this.SIGNUP_LIMIT = {
       VALIDATORS: [ Validators.required, Validators.min(-1), Validators.pattern('-?[0-9]+') ],
       MESSAGES: {
-        'required': this.i18n('Signup limit is required.'),
-        'min': this.i18n('Signup limit must be greater than 1.'),
-        'pattern': this.i18n('Signup limit must be a number.')
+        'required': $localize`Signup limit is required.`,
+        'min': $localize`Signup limit must be greater than 1.`,
+        'pattern': $localize`Signup limit must be a number.`
       }
     }
 
     this.ADMIN_EMAIL = {
       VALIDATORS: [ Validators.required, Validators.email ],
       MESSAGES: {
-        'required': this.i18n('Admin email is required.'),
-        'email': this.i18n('Admin email must be valid.')
+        'required': $localize`Admin email is required.`,
+        'email': $localize`Admin email must be valid.`
       }
     }
 
     this.TRANSCODING_THREADS = {
       VALIDATORS: [ Validators.required, Validators.min(0) ],
       MESSAGES: {
-        'required': this.i18n('Transcoding threads is required.'),
-        'min': this.i18n('Transcoding threads must be greater or equal to 0.')
+        'required': $localize`Transcoding threads is required.`,
+        'min': $localize`Transcoding threads must be greater or equal to 0.`
       }
     }
 
     this.INDEX_URL = {
       VALIDATORS: [ Validators.pattern(/^https:\/\//) ],
       MESSAGES: {
-        'pattern': this.i18n('Index URL should be a URL')
+        'pattern': $localize`Index URL should be a URL`
       }
     }
 
     this.SEARCH_INDEX_URL = {
       VALIDATORS: [ Validators.pattern(/^https?:\/\//) ],
       MESSAGES: {
-        'pattern': this.i18n('Search index URL should be a URL')
+        'pattern': $localize`Search index URL should be a URL`
       }
     }
   }