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 --- .../custom-config-validators.service.ts | 41 +++++++++++----------- 1 file changed, 20 insertions(+), 21 deletions(-) (limited to 'client/src/app/shared/shared-forms/form-validators/custom-config-validators.service.ts') 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 @@ +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` } } } -- cgit v1.2.3