]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/shared-forms/form-validators/video-validators.service.ts
Migrate to $localize
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-forms / form-validators / video-validators.service.ts
index c96e4ef66b37243871a0a60250493ad42b6e71e3..8119c1ae72652b2cd6385b242f3ca63360722572 100644 (file)
@@ -1,6 +1,5 @@
-import { I18n } from '@ngx-translate/i18n-polyfill'
-import { Validators, ValidatorFn, ValidationErrors, AbstractControl } from '@angular/forms'
 import { Injectable } from '@angular/core'
+import { AbstractControl, ValidationErrors, ValidatorFn, Validators } from '@angular/forms'
 import { BuildFormValidator } from './form-validator.service'
 
 @Injectable()
@@ -19,21 +18,21 @@ export class VideoValidatorsService {
   readonly VIDEO_SCHEDULE_PUBLICATION_AT: BuildFormValidator
   readonly VIDEO_ORIGINALLY_PUBLISHED_AT: BuildFormValidator
 
-  constructor (private i18n: I18n) {
+  constructor () {
 
     this.VIDEO_NAME = {
       VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(120) ],
       MESSAGES: {
-        'required': this.i18n('Video name is required.'),
-        'minlength': this.i18n('Video name must be at least 3 characters long.'),
-        'maxlength': this.i18n('Video name cannot be more than 120 characters long.')
+        'required': $localize`Video name is required.`,
+        'minlength': $localize`Video name must be at least 3 characters long.`,
+        'maxlength': $localize`Video name cannot be more than 120 characters long.`
       }
     }
 
     this.VIDEO_PRIVACY = {
       VALIDATORS: [ Validators.required ],
       MESSAGES: {
-        'required': this.i18n('Video privacy is required.')
+        'required': $localize`Video privacy is required.`
       }
     }
 
@@ -60,46 +59,46 @@ export class VideoValidatorsService {
     this.VIDEO_CHANNEL = {
       VALIDATORS: [ Validators.required ],
       MESSAGES: {
-        'required': this.i18n('Video channel is required.')
+        'required': $localize`Video channel is required.`
       }
     }
 
     this.VIDEO_DESCRIPTION = {
       VALIDATORS: [ Validators.minLength(3), Validators.maxLength(10000) ],
       MESSAGES: {
-        'minlength': this.i18n('Video description must be at least 3 characters long.'),
-        'maxlength': this.i18n('Video description cannot be more than 10000 characters long.')
+        'minlength': $localize`Video description must be at least 3 characters long.`,
+        'maxlength': $localize`Video description cannot be more than 10000 characters long.`
       }
     }
 
     this.VIDEO_TAG = {
       VALIDATORS: [ Validators.minLength(2), Validators.maxLength(30) ],
       MESSAGES: {
-        'minlength': this.i18n('A tag should be more than 2 characters long.'),
-        'maxlength': this.i18n('A tag should be less than 30 characters long.')
+        'minlength': $localize`A tag should be more than 2 characters long.`,
+        'maxlength': $localize`A tag should be less than 30 characters long.`
       }
     }
 
     this.VIDEO_TAGS_ARRAY = {
       VALIDATORS: [ Validators.maxLength(5), this.arrayTagLengthValidator() ],
       MESSAGES: {
-        'maxlength': this.i18n('A maximum of 5 tags can be used on a video.'),
-        'arrayTagLength': this.i18n('A tag should be more than 2, and less than 30 characters long.')
+        'maxlength': $localize`A maximum of 5 tags can be used on a video.`,
+        'arrayTagLength': $localize`A tag should be more than 2, and less than 30 characters long.`
       }
     }
 
     this.VIDEO_SUPPORT = {
       VALIDATORS: [ Validators.minLength(3), Validators.maxLength(1000) ],
       MESSAGES: {
-        'minlength': this.i18n('Video support must be at least 3 characters long.'),
-        'maxlength': this.i18n('Video support cannot be more than 1000 characters long.')
+        'minlength': $localize`Video support must be at least 3 characters long.`,
+        'maxlength': $localize`Video support cannot be more than 1000 characters long.`
       }
     }
 
     this.VIDEO_SCHEDULE_PUBLICATION_AT = {
       VALIDATORS: [ ],
       MESSAGES: {
-        'required': this.i18n('A date is required to schedule video update.')
+        'required': $localize`A date is required to schedule video update.`
       }
     }