From 66357162f8e1227495f09bd4f68446aad7071c6d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 12 Aug 2020 10:40:04 +0200 Subject: 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 --- .../form-validators/instance-validators.service.ts | 27 +++++++++++----------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'client/src/app/shared/shared-forms/form-validators/instance-validators.service.ts') 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 @@ -import { I18n } from '@ngx-translate/i18n-polyfill' +import { Injectable } from '@angular/core' import { Validators } from '@angular/forms' import { BuildFormValidator } from './form-validator.service' -import { Injectable } from '@angular/core' @Injectable() export class InstanceValidatorsService { @@ -10,13 +9,13 @@ export class InstanceValidatorsService { readonly SUBJECT: BuildFormValidator readonly BODY: BuildFormValidator - constructor (private i18n: I18n) { + constructor () { this.FROM_EMAIL = { VALIDATORS: [ Validators.required, Validators.email ], MESSAGES: { - 'required': this.i18n('Email is required.'), - 'email': this.i18n('Email must be valid.') + 'required': $localize`Email is required.`, + 'email': $localize`Email must be valid.` } } @@ -27,9 +26,9 @@ export class InstanceValidatorsService { Validators.maxLength(120) ], MESSAGES: { - 'required': this.i18n('Your name is required.'), - 'minlength': this.i18n('Your name must be at least 1 character long.'), - 'maxlength': this.i18n('Your name cannot be more than 120 characters long.') + 'required': $localize`Your name is required.`, + 'minlength': $localize`Your name must be at least 1 character long.`, + 'maxlength': $localize`Your name cannot be more than 120 characters long.` } } @@ -40,9 +39,9 @@ export class InstanceValidatorsService { Validators.maxLength(120) ], MESSAGES: { - 'required': this.i18n('A subject is required.'), - 'minlength': this.i18n('The subject must be at least 1 character long.'), - 'maxlength': this.i18n('The subject cannot be more than 120 characters long.') + 'required': $localize`A subject is required.`, + 'minlength': $localize`The subject must be at least 1 character long.`, + 'maxlength': $localize`The subject cannot be more than 120 characters long.` } } @@ -53,9 +52,9 @@ export class InstanceValidatorsService { Validators.maxLength(5000) ], MESSAGES: { - 'required': this.i18n('A message is required.'), - 'minlength': this.i18n('The message must be at least 3 characters long.'), - 'maxlength': this.i18n('The message cannot be more than 5000 characters long.') + 'required': $localize`A message is required.`, + 'minlength': $localize`The message must be at least 3 characters long.`, + 'maxlength': $localize`The message cannot be more than 5000 characters long.` } } } -- cgit v1.2.3