From e309822b93d9b69f30cbe830ef3d09dfdb2c13b2 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 5 Jun 2018 15:01:45 +0200 Subject: [PATCH] Add form validator translations --- .../edit-custom-config.component.html | 2 +- .../edit-custom-config.component.ts | 38 +- .../users/user-edit/user-create.component.ts | 13 +- .../users/user-edit/user-update.component.ts | 10 +- .../my-account-change-password.component.ts | 8 +- .../my-account-profile.component.html | 32 +- .../my-account-profile.component.scss | 5 +- .../my-account-profile.component.ts | 8 +- ...-account-video-channel-create.component.ts | 13 +- ...-account-video-channel-update.component.ts | 13 +- client/src/app/app.module.ts | 6 + client/src/app/login/login.component.ts | 7 +- .../reset-password.component.ts | 10 +- .../custom-config-validators.service.ts | 72 +++ .../forms/form-validators/custom-config.ts | 56 -- .../form-validators/form-validator.service.ts | 9 +- .../app/shared/forms/form-validators/index.ts | 11 +- .../login-validators.service.ts | 30 + .../app/shared/forms/form-validators/login.ts | 18 - .../reset-password-validators.service.ts | 20 + .../forms/form-validators/reset-password.ts | 10 - .../user-validators.service.ts | 93 +++ .../app/shared/forms/form-validators/user.ts | 70 --- .../form-validators/validator-message.ts | 5 - .../video-abuse-validators.service.ts | 20 + .../forms/form-validators/video-abuse.ts | 10 - .../video-channel-validators.service.ts | 48 ++ .../forms/form-validators/video-channel.ts | 34 - .../video-comment-validators.service.ts | 20 + .../forms/form-validators/video-comment.ts | 10 - .../video-validators.service.ts | 88 +++ .../app/shared/forms/form-validators/video.ts | 68 -- client/src/app/shared/shared.module.ts | 16 + client/src/app/signup/signup.component.ts | 10 +- .../shared/video-edit.component.ts | 43 +- .../comment/video-comment-add.component.ts | 5 +- .../modal/video-report.component.ts | 8 +- client/src/locale/source/messages_en_US.xml | 535 +++++++++++++--- client/src/locale/target/messages_fr.xml | 583 ++++++++++++++---- client/src/main.ts | 14 +- 40 files changed, 1476 insertions(+), 595 deletions(-) create mode 100644 client/src/app/shared/forms/form-validators/custom-config-validators.service.ts delete mode 100644 client/src/app/shared/forms/form-validators/custom-config.ts create mode 100644 client/src/app/shared/forms/form-validators/login-validators.service.ts delete mode 100644 client/src/app/shared/forms/form-validators/login.ts create mode 100644 client/src/app/shared/forms/form-validators/reset-password-validators.service.ts delete mode 100644 client/src/app/shared/forms/form-validators/reset-password.ts create mode 100644 client/src/app/shared/forms/form-validators/user-validators.service.ts delete mode 100644 client/src/app/shared/forms/form-validators/user.ts delete mode 100644 client/src/app/shared/forms/form-validators/validator-message.ts create mode 100644 client/src/app/shared/forms/form-validators/video-abuse-validators.service.ts delete mode 100644 client/src/app/shared/forms/form-validators/video-abuse.ts create mode 100644 client/src/app/shared/forms/form-validators/video-channel-validators.service.ts delete mode 100644 client/src/app/shared/forms/form-validators/video-channel.ts create mode 100644 client/src/app/shared/forms/form-validators/video-comment-validators.service.ts delete mode 100644 client/src/app/shared/forms/form-validators/video-comment.ts create mode 100644 client/src/app/shared/forms/form-validators/video-validators.service.ts delete mode 100644 client/src/app/shared/forms/form-validators/video.ts diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html index 4263b7b5f..a0bd01e5e 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html +++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html @@ -207,7 +207,7 @@ Check this checkbox, save the configuration and test with a video URL of your in
Cache
- + { diff --git a/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts b/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts index 56e644f39..7be7aabc2 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts +++ b/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts @@ -1,8 +1,9 @@ import { Component, OnInit } from '@angular/core' import { NotificationsService } from 'angular2-notifications' -import { FormReactive, USER_PASSWORD, UserService } from '../../../shared' +import { FormReactive, UserService } from '../../../shared' import { I18n } from '@ngx-translate/i18n-polyfill' import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' +import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service' @Component({ selector: 'my-account-change-password', @@ -14,6 +15,7 @@ export class MyAccountChangePasswordComponent extends FormReactive implements On constructor ( protected formValidatorService: FormValidatorService, + private userValidatorsService: UserValidatorsService, private notificationsService: NotificationsService, private userService: UserService, private i18n: I18n @@ -23,8 +25,8 @@ export class MyAccountChangePasswordComponent extends FormReactive implements On ngOnInit () { this.buildForm({ - 'new-password': USER_PASSWORD, - 'new-confirmed-password': USER_PASSWORD + 'new-password': this.userValidatorsService.USER_PASSWORD, + 'new-confirmed-password': this.userValidatorsService.USER_PASSWORD }) } diff --git a/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.html b/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.html index bbdce5b02..05c0b5ddc 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.html +++ b/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.html @@ -2,22 +2,26 @@
- - -
- {{ formErrors['display-name'] }} +
+ + +
+ {{ formErrors['display-name'] }} +
- - -
- {{ formErrors.description }} +
+ + +
+ {{ formErrors.description }} +
diff --git a/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.scss b/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.scss index fc2b92c89..6aabb60f4 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.scss +++ b/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.scss @@ -1,11 +1,14 @@ @import '_variables'; @import '_mixins'; +.form-group:first-child { + margin-bottom: 15px; +} + input[type=text] { @include peertube-input-text(340px); display: block; - margin-bottom: 15px; } textarea { diff --git a/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts b/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts index 1fe337da0..400c3b889 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts +++ b/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts @@ -1,10 +1,11 @@ import { Component, Input, OnInit } from '@angular/core' import { NotificationsService } from 'angular2-notifications' -import { FormReactive, USER_DESCRIPTION, USER_DISPLAY_NAME, UserService } from '../../../shared' +import { FormReactive, UserService } from '../../../shared' import { User } from '@app/shared' import { I18n } from '@ngx-translate/i18n-polyfill' import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' import { Subject } from 'rxjs/Subject' +import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service' @Component({ selector: 'my-account-profile', @@ -19,6 +20,7 @@ export class MyAccountProfileComponent extends FormReactive implements OnInit { constructor ( protected formValidatorService: FormValidatorService, + private userValidatorsService: UserValidatorsService, private notificationsService: NotificationsService, private userService: UserService, private i18n: I18n @@ -28,8 +30,8 @@ export class MyAccountProfileComponent extends FormReactive implements OnInit { ngOnInit () { this.buildForm({ - 'display-name': USER_DISPLAY_NAME, - description: USER_DESCRIPTION + 'display-name': this.userValidatorsService.USER_DISPLAY_NAME, + description: this.userValidatorsService.USER_DESCRIPTION }) this.userInformationLoaded.subscribe(() => { diff --git a/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-create.component.ts b/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-create.component.ts index e38eaae9c..c0eaa4763 100644 --- a/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-create.component.ts +++ b/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-create.component.ts @@ -3,15 +3,11 @@ import { Router } from '@angular/router' import { NotificationsService } from 'angular2-notifications' import { MyAccountVideoChannelEdit } from './my-account-video-channel-edit' import { VideoChannelCreate } from '../../../../../shared/models/videos' -import { - VIDEO_CHANNEL_DESCRIPTION, - VIDEO_CHANNEL_DISPLAY_NAME, - VIDEO_CHANNEL_SUPPORT -} from '@app/shared/forms/form-validators/video-channel' import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' import { AuthService } from '@app/core' import { I18n } from '@ngx-translate/i18n-polyfill' import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' +import { VideoChannelValidatorsService } from '@app/shared/forms/form-validators/video-channel-validators.service' @Component({ selector: 'my-account-video-channel-create', @@ -24,6 +20,7 @@ export class MyAccountVideoChannelCreateComponent extends MyAccountVideoChannelE constructor ( protected formValidatorService: FormValidatorService, private authService: AuthService, + private videoChannelValidatorsService: VideoChannelValidatorsService, private notificationsService: NotificationsService, private router: Router, private videoChannelService: VideoChannelService, @@ -34,9 +31,9 @@ export class MyAccountVideoChannelCreateComponent extends MyAccountVideoChannelE ngOnInit () { this.buildForm({ - 'display-name': VIDEO_CHANNEL_DISPLAY_NAME, - description: VIDEO_CHANNEL_DESCRIPTION, - support: VIDEO_CHANNEL_SUPPORT + 'display-name': this.videoChannelValidatorsService.VIDEO_CHANNEL_DISPLAY_NAME, + description: this.videoChannelValidatorsService.VIDEO_CHANNEL_DESCRIPTION, + support: this.videoChannelValidatorsService.VIDEO_CHANNEL_SUPPORT }) } diff --git a/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-update.component.ts b/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-update.component.ts index eda03374a..1510c5015 100644 --- a/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-update.component.ts +++ b/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-update.component.ts @@ -3,17 +3,13 @@ import { ActivatedRoute, Router } from '@angular/router' import { NotificationsService } from 'angular2-notifications' import { MyAccountVideoChannelEdit } from './my-account-video-channel-edit' import { VideoChannelUpdate } from '../../../../../shared/models/videos' -import { - VIDEO_CHANNEL_DESCRIPTION, - VIDEO_CHANNEL_DISPLAY_NAME, - VIDEO_CHANNEL_SUPPORT -} from '@app/shared/forms/form-validators/video-channel' import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' import { Subscription } from 'rxjs' import { VideoChannel } from '@app/shared/video-channel/video-channel.model' import { AuthService } from '@app/core' import { I18n } from '@ngx-translate/i18n-polyfill' import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' +import { VideoChannelValidatorsService } from '@app/shared/forms/form-validators/video-channel-validators.service' @Component({ selector: 'my-account-video-channel-update', @@ -29,6 +25,7 @@ export class MyAccountVideoChannelUpdateComponent extends MyAccountVideoChannelE constructor ( protected formValidatorService: FormValidatorService, private authService: AuthService, + private videoChannelValidatorsService: VideoChannelValidatorsService, private notificationsService: NotificationsService, private router: Router, private route: ActivatedRoute, @@ -40,9 +37,9 @@ export class MyAccountVideoChannelUpdateComponent extends MyAccountVideoChannelE ngOnInit () { this.buildForm({ - 'display-name': VIDEO_CHANNEL_DISPLAY_NAME, - description: VIDEO_CHANNEL_DESCRIPTION, - support: VIDEO_CHANNEL_SUPPORT + 'display-name': this.videoChannelValidatorsService.VIDEO_CHANNEL_DISPLAY_NAME, + description: this.videoChannelValidatorsService.VIDEO_CHANNEL_DESCRIPTION, + support: this.videoChannelValidatorsService.VIDEO_CHANNEL_SUPPORT }) this.paramsSub = this.route.params.subscribe(routeParams => { diff --git a/client/src/app/app.module.ts b/client/src/app/app.module.ts index 44552021f..9992b9c44 100644 --- a/client/src/app/app.module.ts +++ b/client/src/app/app.module.ts @@ -17,6 +17,7 @@ import { SharedModule } from './shared' import { SignupModule } from './signup' import { VideosModule } from './videos' import { buildFileLocale, getDefaultLocale } from '../../../shared/models/i18n' +import { environment } from '../environments/environment' export function metaFactory (serverService: ServerService): MetaLoader { return new MetaStaticLoader({ @@ -66,6 +67,11 @@ export function metaFactory (serverService: ServerService): MetaLoader { { provide: TRANSLATIONS, useFactory: (locale) => { + // On dev mode, test locales + if (environment.production === false && window.location.search === '?lang=fr') { + return require(`raw-loader!../locale/target/messages_fr.xml`) + } + const fileLocale = buildFileLocale(locale) // Default locale, nothing to translate diff --git a/client/src/app/login/login.component.ts b/client/src/app/login/login.component.ts index f7aad06e8..a91522db3 100644 --- a/client/src/app/login/login.component.ts +++ b/client/src/app/login/login.component.ts @@ -7,7 +7,7 @@ import { AuthService } from '../core' import { FormReactive } from '../shared' import { I18n } from '@ngx-translate/i18n-polyfill' import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' -import { LOGIN_PASSWORD, LOGIN_USERNAME } from '@app/shared/forms/form-validators/login' +import { LoginValidatorsService } from '@app/shared/forms/form-validators/login-validators.service' @Component({ selector: 'my-login', @@ -24,6 +24,7 @@ export class LoginComponent extends FormReactive implements OnInit { constructor ( protected formValidatorService: FormValidatorService, + private loginValidatorsService: LoginValidatorsService, private authService: AuthService, private userService: UserService, private serverService: ServerService, @@ -40,8 +41,8 @@ export class LoginComponent extends FormReactive implements OnInit { ngOnInit () { this.buildForm({ - username: LOGIN_USERNAME, - password: LOGIN_PASSWORD + username: this.loginValidatorsService.LOGIN_USERNAME, + password: this.loginValidatorsService.LOGIN_PASSWORD }) } diff --git a/client/src/app/reset-password/reset-password.component.ts b/client/src/app/reset-password/reset-password.component.ts index 58e086f45..cb4a634f1 100644 --- a/client/src/app/reset-password/reset-password.component.ts +++ b/client/src/app/reset-password/reset-password.component.ts @@ -1,12 +1,12 @@ import { Component, OnInit } from '@angular/core' import { ActivatedRoute, Router } from '@angular/router' -import { USER_PASSWORD, UserService } from '@app/shared' +import { UserService, UserValidatorsService } from '@app/shared' import { NotificationsService } from 'angular2-notifications' import { AuthService } from '../core' import { FormReactive } from '../shared' import { I18n } from '@ngx-translate/i18n-polyfill' -import { RESET_PASSWORD_CONFIRM } from '@app/shared/forms/form-validators/reset-password' import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' +import { ResetPasswordValidatorsService } from '@app/shared/forms/form-validators/reset-password-validators.service' @Component({ selector: 'my-login', @@ -20,6 +20,8 @@ export class ResetPasswordComponent extends FormReactive implements OnInit { constructor ( protected formValidatorService: FormValidatorService, + private resetPasswordValidatorsService: ResetPasswordValidatorsService, + private userValidatorsService: UserValidatorsService, private authService: AuthService, private userService: UserService, private notificationsService: NotificationsService, @@ -32,8 +34,8 @@ export class ResetPasswordComponent extends FormReactive implements OnInit { ngOnInit () { this.buildForm({ - password: USER_PASSWORD, - 'password-confirm': RESET_PASSWORD_CONFIRM + password: this.userValidatorsService.USER_PASSWORD, + 'password-confirm': this.resetPasswordValidatorsService.RESET_PASSWORD_CONFIRM }) this.userId = this.route.snapshot.queryParams['userId'] diff --git a/client/src/app/shared/forms/form-validators/custom-config-validators.service.ts b/client/src/app/shared/forms/form-validators/custom-config-validators.service.ts new file mode 100644 index 000000000..1b36bbc6b --- /dev/null +++ b/client/src/app/shared/forms/form-validators/custom-config-validators.service.ts @@ -0,0 +1,72 @@ +import { Validators } from '@angular/forms' +import { I18n } from '@ngx-translate/i18n-polyfill' +import { BuildFormValidator } from '@app/shared' +import { Injectable } from '@angular/core' + +@Injectable() +export class CustomConfigValidatorsService { + readonly INSTANCE_NAME: BuildFormValidator + readonly INSTANCE_SHORT_DESCRIPTION: BuildFormValidator + readonly SERVICES_TWITTER_USERNAME: BuildFormValidator + readonly CACHE_PREVIEWS_SIZE: BuildFormValidator + readonly SIGNUP_LIMIT: BuildFormValidator + readonly ADMIN_EMAIL: BuildFormValidator + readonly TRANSCODING_THREADS: BuildFormValidator + + constructor (private i18n: I18n) { + this.INSTANCE_NAME = { + VALIDATORS: [ Validators.required ], + MESSAGES: { + 'required': this.i18n('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.') + } + } + + this.SERVICES_TWITTER_USERNAME = { + VALIDATORS: [ Validators.required ], + MESSAGES: { + 'required': this.i18n('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.') + } + } + + 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.') + } + } + + this.ADMIN_EMAIL = { + VALIDATORS: [ Validators.required, Validators.email ], + MESSAGES: { + 'required': this.i18n('Admin email is required.'), + 'email': this.i18n('Admin email must be valid.') + } + } + + this.TRANSCODING_THREADS = { + VALIDATORS: [ Validators.required, Validators.min(1) ], + MESSAGES: { + 'required': this.i18n('Transcoding threads is required.'), + 'min': this.i18n('Transcoding threads must be greater than 1.') + } + } + } +} diff --git a/client/src/app/shared/forms/form-validators/custom-config.ts b/client/src/app/shared/forms/form-validators/custom-config.ts deleted file mode 100644 index e3d9a4c7b..000000000 --- a/client/src/app/shared/forms/form-validators/custom-config.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { Validators } from '@angular/forms' - -export const INSTANCE_NAME = { - VALIDATORS: [ Validators.required ], - MESSAGES: { - 'required': 'Instance name is required.' - } -} - -export const INSTANCE_SHORT_DESCRIPTION = { - VALIDATORS: [ Validators.max(250) ], - MESSAGES: { - 'max': 'Short description should not be longer than 250 characters.' - } -} - -export const SERVICES_TWITTER_USERNAME = { - VALIDATORS: [ Validators.required ], - MESSAGES: { - 'required': 'Twitter username is required.' - } -} - -export const CACHE_PREVIEWS_SIZE = { - VALIDATORS: [ Validators.required, Validators.min(1), Validators.pattern('[0-9]+') ], - MESSAGES: { - 'required': 'Preview cache size is required.', - 'min': 'Preview cache size must be greater than 1.', - 'pattern': 'Preview cache size must be a number.' - } -} - -export const SIGNUP_LIMIT = { - VALIDATORS: [ Validators.required, Validators.min(1), Validators.pattern('[0-9]+') ], - MESSAGES: { - 'required': 'Signup limit is required.', - 'min': 'Signup limit must be greater than 1.', - 'pattern': 'Preview cache size must be a number.' - } -} - -export const ADMIN_EMAIL = { - VALIDATORS: [ Validators.required, Validators.email ], - MESSAGES: { - 'required': 'Admin email is required.', - 'email': 'Admin email must be valid.' - } -} - -export const TRANSCODING_THREADS = { - VALIDATORS: [ Validators.required, Validators.min(1) ], - MESSAGES: { - 'required': 'Transcoding threads is required.', - 'min': 'Transcoding threads must be greater than 1.' - } -} diff --git a/client/src/app/shared/forms/form-validators/form-validator.service.ts b/client/src/app/shared/forms/form-validators/form-validator.service.ts index 5c3d3e4bd..d10e17ca7 100644 --- a/client/src/app/shared/forms/form-validators/form-validator.service.ts +++ b/client/src/app/shared/forms/form-validators/form-validator.service.ts @@ -3,11 +3,12 @@ import { Injectable } from '@angular/core' import { FormReactiveErrors, FormReactiveValidationMessages } from '@app/shared/forms/form-reactive' import { I18n } from '@ngx-translate/i18n-polyfill' +export type BuildFormValidator = { + VALIDATORS: ValidatorFn[], + MESSAGES: { [ name: string ]: string } +} export type BuildFormArgument = { - [ id: string ]: { - VALIDATORS: ValidatorFn[], - MESSAGES: { [ name: string ]: string } - } + [ id: string ]: BuildFormValidator } export type BuildFormDefaultValues = { [ name: string ]: string | string[] diff --git a/client/src/app/shared/forms/form-validators/index.ts b/client/src/app/shared/forms/form-validators/index.ts index cf544b2a9..487683088 100644 --- a/client/src/app/shared/forms/form-validators/index.ts +++ b/client/src/app/shared/forms/form-validators/index.ts @@ -1,5 +1,10 @@ +export * from './custom-config-validators.service' export * from './form-validator.service' export * from './host' -export * from './user' -export * from './video-abuse' -export * from './video' +export * from './login-validators.service' +export * from './reset-password-validators.service' +export * from './user-validators.service' +export * from './video-abuse-validators.service' +export * from './video-channel-validators.service' +export * from './video-comment-validators.service' +export * from './video-validators.service' diff --git a/client/src/app/shared/forms/form-validators/login-validators.service.ts b/client/src/app/shared/forms/form-validators/login-validators.service.ts new file mode 100644 index 000000000..9d68f830c --- /dev/null +++ b/client/src/app/shared/forms/form-validators/login-validators.service.ts @@ -0,0 +1,30 @@ +import { I18n } from '@ngx-translate/i18n-polyfill' +import { Validators } from '@angular/forms' +import { Injectable } from '@angular/core' +import { BuildFormValidator } from '@app/shared' + +@Injectable() +export class LoginValidatorsService { + readonly LOGIN_USERNAME: BuildFormValidator + readonly LOGIN_PASSWORD: BuildFormValidator + + constructor (private i18n: I18n) { + this.LOGIN_USERNAME = { + VALIDATORS: [ + Validators.required + ], + MESSAGES: { + 'required': this.i18n('Username is required.') + } + } + + this.LOGIN_PASSWORD = { + VALIDATORS: [ + Validators.required + ], + MESSAGES: { + 'required': this.i18n('Password is required.') + } + } + } +} diff --git a/client/src/app/shared/forms/form-validators/login.ts b/client/src/app/shared/forms/form-validators/login.ts deleted file mode 100644 index f37f8d285..000000000 --- a/client/src/app/shared/forms/form-validators/login.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Validators } from '@angular/forms' - -export const LOGIN_USERNAME = { - VALIDATORS: [ - Validators.required - ], - MESSAGES: { - 'required': 'Username is required.' - } -} -export const LOGIN_PASSWORD = { - VALIDATORS: [ - Validators.required - ], - MESSAGES: { - 'required': 'Password is required.' - } -} diff --git a/client/src/app/shared/forms/form-validators/reset-password-validators.service.ts b/client/src/app/shared/forms/form-validators/reset-password-validators.service.ts new file mode 100644 index 000000000..df206254d --- /dev/null +++ b/client/src/app/shared/forms/form-validators/reset-password-validators.service.ts @@ -0,0 +1,20 @@ +import { I18n } from '@ngx-translate/i18n-polyfill' +import { Validators } from '@angular/forms' +import { Injectable } from '@angular/core' +import { BuildFormValidator } from '@app/shared' + +@Injectable() +export class ResetPasswordValidatorsService { + readonly RESET_PASSWORD_CONFIRM: BuildFormValidator + + constructor (private i18n: I18n) { + this.RESET_PASSWORD_CONFIRM = { + VALIDATORS: [ + Validators.required + ], + MESSAGES: { + 'required': this.i18n('Confirmation of the password is required.') + } + } + } +} diff --git a/client/src/app/shared/forms/form-validators/reset-password.ts b/client/src/app/shared/forms/form-validators/reset-password.ts deleted file mode 100644 index 7dafdef9a..000000000 --- a/client/src/app/shared/forms/form-validators/reset-password.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Validators } from '@angular/forms' - -export const RESET_PASSWORD_CONFIRM = { - VALIDATORS: [ - Validators.required - ], - MESSAGES: { - 'required': 'Confirmation of the password is required.' - } -} diff --git a/client/src/app/shared/forms/form-validators/user-validators.service.ts b/client/src/app/shared/forms/form-validators/user-validators.service.ts new file mode 100644 index 000000000..bb6ff2068 --- /dev/null +++ b/client/src/app/shared/forms/form-validators/user-validators.service.ts @@ -0,0 +1,93 @@ +import { I18n } from '@ngx-translate/i18n-polyfill' +import { Validators } from '@angular/forms' +import { BuildFormValidator } from '@app/shared' +import { Injectable } from '@angular/core' + +@Injectable() +export class UserValidatorsService { + readonly USER_USERNAME: BuildFormValidator + readonly USER_EMAIL: BuildFormValidator + readonly USER_PASSWORD: BuildFormValidator + readonly USER_VIDEO_QUOTA: BuildFormValidator + readonly USER_ROLE: BuildFormValidator + readonly USER_DISPLAY_NAME: BuildFormValidator + readonly USER_DESCRIPTION: BuildFormValidator + + constructor (private i18n: I18n) { + + this.USER_USERNAME = { + VALIDATORS: [ + Validators.required, + Validators.minLength(3), + Validators.maxLength(20), + Validators.pattern(/^[a-z0-9._]+$/) + ], + MESSAGES: { + 'required': this.i18n('Username is required.'), + 'minlength': this.i18n('Username must be at least 3 characters long.'), + 'maxlength': this.i18n('Username cannot be more than 20 characters long.'), + 'pattern': this.i18n('Username should be only lowercase alphanumeric characters.') + } + } + + this.USER_EMAIL = { + VALIDATORS: [ Validators.required, Validators.email ], + MESSAGES: { + 'required': this.i18n('Email is required.'), + 'email': this.i18n('Email must be valid.') + } + } + + this.USER_PASSWORD = { + VALIDATORS: [ + Validators.required, + Validators.minLength(6), + Validators.maxLength(255) + ], + MESSAGES: { + 'required': this.i18n('Password is required.'), + 'minlength': this.i18n('Password must be at least 6 characters long.'), + 'maxlength': this.i18n('Password cannot be more than 255 characters long.') + } + } + + this.USER_VIDEO_QUOTA = { + VALIDATORS: [ Validators.required, Validators.min(-1) ], + MESSAGES: { + 'required': this.i18n('Video quota is required.'), + 'min': this.i18n('Quota must be greater than -1.') + } + } + + this.USER_ROLE = { + VALIDATORS: [ Validators.required ], + MESSAGES: { + 'required': this.i18n('User role is required.') + } + } + + this.USER_DISPLAY_NAME = { + VALIDATORS: [ + Validators.required, + Validators.minLength(3), + Validators.maxLength(120) + ], + MESSAGES: { + 'required': this.i18n('Display name is required.'), + 'minlength': this.i18n('Display name must be at least 3 characters long.'), + 'maxlength': this.i18n('Display name cannot be more than 120 characters long.') + } + } + + this.USER_DESCRIPTION = { + VALIDATORS: [ + Validators.minLength(3), + Validators.maxLength(250) + ], + MESSAGES: { + 'minlength': this.i18n('Description must be at least 3 characters long.'), + 'maxlength': this.i18n('Description cannot be more than 250 characters long.') + } + } + } +} diff --git a/client/src/app/shared/forms/form-validators/user.ts b/client/src/app/shared/forms/form-validators/user.ts deleted file mode 100644 index 0973f1b00..000000000 --- a/client/src/app/shared/forms/form-validators/user.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { Validators } from '@angular/forms' - -export const USER_USERNAME = { - VALIDATORS: [ - Validators.required, - Validators.minLength(3), - Validators.maxLength(20), - Validators.pattern(/^[a-z0-9._]+$/) - ], - MESSAGES: { - 'required': 'Username is required.', - 'minlength': 'Username must be at least 3 characters long.', - 'maxlength': 'Username cannot be more than 20 characters long.', - 'pattern': 'Username should be only lowercase alphanumeric characters.' - } -} -export const USER_EMAIL = { - VALIDATORS: [ Validators.required, Validators.email ], - MESSAGES: { - 'required': 'Email is required.', - 'email': 'Email must be valid.' - } -} -export const USER_PASSWORD = { - VALIDATORS: [ - Validators.required, - Validators.minLength(6), - Validators.maxLength(255) - ], - MESSAGES: { - 'required': 'Password is required.', - 'minlength': 'Password must be at least 6 characters long.', - 'maxlength': 'Password cannot be more than 255 characters long.' - } -} -export const USER_VIDEO_QUOTA = { - VALIDATORS: [ Validators.required, Validators.min(-1) ], - MESSAGES: { - 'required': 'Video quota is required.', - 'min': 'Quota must be greater than -1.' - } -} -export const USER_ROLE = { - VALIDATORS: [ Validators.required ], - MESSAGES: { - 'required': 'User role is required.' - } -} -export const USER_DISPLAY_NAME = { - VALIDATORS: [ - Validators.required, - Validators.minLength(3), - Validators.maxLength(120) - ], - MESSAGES: { - 'required': 'Display name is required.', - 'minlength': 'Display name must be at least 3 characters long.', - 'maxlength': 'Display name cannot be more than 120 characters long.' - } -} -export const USER_DESCRIPTION = { - VALIDATORS: [ - Validators.minLength(3), - Validators.maxLength(250) - ], - MESSAGES: { - 'minlength': 'Description must be at least 3 characters long.', - 'maxlength': 'Description cannot be more than 250 characters long.' - } -} diff --git a/client/src/app/shared/forms/form-validators/validator-message.ts b/client/src/app/shared/forms/form-validators/validator-message.ts deleted file mode 100644 index 5ce45833b..000000000 --- a/client/src/app/shared/forms/form-validators/validator-message.ts +++ /dev/null @@ -1,5 +0,0 @@ -export type ValidatorMessage = { - [ id: string ]: { - [ error: string ]: string - } -} diff --git a/client/src/app/shared/forms/form-validators/video-abuse-validators.service.ts b/client/src/app/shared/forms/form-validators/video-abuse-validators.service.ts new file mode 100644 index 000000000..774e6a488 --- /dev/null +++ b/client/src/app/shared/forms/form-validators/video-abuse-validators.service.ts @@ -0,0 +1,20 @@ +import { I18n } from '@ngx-translate/i18n-polyfill' +import { Validators } from '@angular/forms' +import { Injectable } from '@angular/core' +import { BuildFormValidator } from '@app/shared' + +@Injectable() +export class VideoAbuseValidatorsService { + readonly VIDEO_ABUSE_REASON: BuildFormValidator + + constructor (private i18n: I18n) { + this.VIDEO_ABUSE_REASON = { + VALIDATORS: [ Validators.required, Validators.minLength(2), Validators.maxLength(300) ], + MESSAGES: { + 'required': this.i18n('Report reason is required.'), + 'minlength': this.i18n('Report reason must be at least 2 characters long.'), + 'maxlength': this.i18n('Report reason cannot be more than 300 characters long.') + } + } + } +} diff --git a/client/src/app/shared/forms/form-validators/video-abuse.ts b/client/src/app/shared/forms/form-validators/video-abuse.ts deleted file mode 100644 index 4b2a2b789..000000000 --- a/client/src/app/shared/forms/form-validators/video-abuse.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Validators } from '@angular/forms' - -export const VIDEO_ABUSE_REASON = { - VALIDATORS: [ Validators.required, Validators.minLength(2), Validators.maxLength(300) ], - MESSAGES: { - 'required': 'Report reason is required.', - 'minlength': 'Report reason must be at least 2 characters long.', - 'maxlength': 'Report reason cannot be more than 300 characters long.' - } -} diff --git a/client/src/app/shared/forms/form-validators/video-channel-validators.service.ts b/client/src/app/shared/forms/form-validators/video-channel-validators.service.ts new file mode 100644 index 000000000..28b063f89 --- /dev/null +++ b/client/src/app/shared/forms/form-validators/video-channel-validators.service.ts @@ -0,0 +1,48 @@ +import { I18n } from '@ngx-translate/i18n-polyfill' +import { Validators } from '@angular/forms' +import { Injectable } from '@angular/core' +import { BuildFormValidator } from '@app/shared' + +@Injectable() +export class VideoChannelValidatorsService { + readonly VIDEO_CHANNEL_DISPLAY_NAME: BuildFormValidator + readonly VIDEO_CHANNEL_DESCRIPTION: BuildFormValidator + readonly VIDEO_CHANNEL_SUPPORT: BuildFormValidator + + constructor (private i18n: I18n) { + this.VIDEO_CHANNEL_DISPLAY_NAME = { + VALIDATORS: [ + Validators.required, + Validators.minLength(3), + Validators.maxLength(120) + ], + MESSAGES: { + 'required': i18n('Display name is required.'), + 'minlength': i18n('Display name must be at least 3 characters long.'), + 'maxlength': i18n('Display name cannot be more than 120 characters long.') + } + } + + this.VIDEO_CHANNEL_DESCRIPTION = { + VALIDATORS: [ + Validators.minLength(3), + Validators.maxLength(500) + ], + MESSAGES: { + 'minlength': i18n('Description must be at least 3 characters long.'), + 'maxlength': i18n('Description cannot be more than 500 characters long.') + } + } + + this.VIDEO_CHANNEL_SUPPORT = { + VALIDATORS: [ + Validators.minLength(3), + Validators.maxLength(500) + ], + MESSAGES: { + 'minlength': i18n('Support text must be at least 3 characters long.'), + 'maxlength': i18n('Support text cannot be more than 500 characters long.') + } + } + } +} diff --git a/client/src/app/shared/forms/form-validators/video-channel.ts b/client/src/app/shared/forms/form-validators/video-channel.ts deleted file mode 100644 index 2185cdaa9..000000000 --- a/client/src/app/shared/forms/form-validators/video-channel.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { Validators } from '@angular/forms' - -export const VIDEO_CHANNEL_DISPLAY_NAME = { - VALIDATORS: [ - Validators.required, - Validators.minLength(3), - Validators.maxLength(120) - ], - MESSAGES: { - 'required': 'Display name is required.', - 'minlength': 'Display name must be at least 3 characters long.', - 'maxlength': 'Display name cannot be more than 120 characters long.' - } -} -export const VIDEO_CHANNEL_DESCRIPTION = { - VALIDATORS: [ - Validators.minLength(3), - Validators.maxLength(500) - ], - MESSAGES: { - 'minlength': 'Description must be at least 3 characters long.', - 'maxlength': 'Description cannot be more than 500 characters long.' - } -} -export const VIDEO_CHANNEL_SUPPORT = { - VALIDATORS: [ - Validators.minLength(3), - Validators.maxLength(500) - ], - MESSAGES: { - 'minlength': 'Support text must be at least 3 characters long.', - 'maxlength': 'Support text cannot be more than 500 characters long.' - } -} diff --git a/client/src/app/shared/forms/form-validators/video-comment-validators.service.ts b/client/src/app/shared/forms/form-validators/video-comment-validators.service.ts new file mode 100644 index 000000000..45c7081ef --- /dev/null +++ b/client/src/app/shared/forms/form-validators/video-comment-validators.service.ts @@ -0,0 +1,20 @@ +import { I18n } from '@ngx-translate/i18n-polyfill' +import { Validators } from '@angular/forms' +import { Injectable } from '@angular/core' +import { BuildFormValidator } from '@app/shared' + +@Injectable() +export class VideoCommentValidatorsService { + readonly VIDEO_COMMENT_TEXT: BuildFormValidator + + constructor (private i18n: I18n) { + this.VIDEO_COMMENT_TEXT = { + VALIDATORS: [ Validators.required, Validators.minLength(1), Validators.maxLength(3000) ], + MESSAGES: { + 'required': this.i18n('Comment is required.'), + 'minlength': this.i18n('Comment must be at least 2 characters long.'), + 'maxlength': this.i18n('Comment cannot be more than 3000 characters long.') + } + } + } +} diff --git a/client/src/app/shared/forms/form-validators/video-comment.ts b/client/src/app/shared/forms/form-validators/video-comment.ts deleted file mode 100644 index 290d83195..000000000 --- a/client/src/app/shared/forms/form-validators/video-comment.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Validators } from '@angular/forms' - -export const VIDEO_COMMENT_TEXT = { - VALIDATORS: [ Validators.required, Validators.minLength(1), Validators.maxLength(3000) ], - MESSAGES: { - 'required': 'Comment is required.', - 'minlength': 'Comment must be at least 2 characters long.', - 'maxlength': 'Comment cannot be more than 3000 characters long.' - } -} diff --git a/client/src/app/shared/forms/form-validators/video-validators.service.ts b/client/src/app/shared/forms/form-validators/video-validators.service.ts new file mode 100644 index 000000000..76fc5cf04 --- /dev/null +++ b/client/src/app/shared/forms/form-validators/video-validators.service.ts @@ -0,0 +1,88 @@ +import { I18n } from '@ngx-translate/i18n-polyfill' +import { Validators } from '@angular/forms' +import { Injectable } from '@angular/core' +import { BuildFormValidator } from '@app/shared' + +@Injectable() +export class VideoValidatorsService { + readonly VIDEO_NAME: BuildFormValidator + readonly VIDEO_PRIVACY: BuildFormValidator + readonly VIDEO_CATEGORY: BuildFormValidator + readonly VIDEO_LICENCE: BuildFormValidator + readonly VIDEO_LANGUAGE: BuildFormValidator + readonly VIDEO_IMAGE: BuildFormValidator + readonly VIDEO_CHANNEL: BuildFormValidator + readonly VIDEO_DESCRIPTION: BuildFormValidator + readonly VIDEO_TAGS: BuildFormValidator + readonly VIDEO_SUPPORT: BuildFormValidator + + constructor (private i18n: I18n) { + + 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.') + } + } + + this.VIDEO_PRIVACY = { + VALIDATORS: [ Validators.required ], + MESSAGES: { + 'required': this.i18n('Video privacy is required.') + } + } + + this.VIDEO_CATEGORY = { + VALIDATORS: [ ], + MESSAGES: {} + } + + this.VIDEO_LICENCE = { + VALIDATORS: [ ], + MESSAGES: {} + } + + this.VIDEO_LANGUAGE = { + VALIDATORS: [ ], + MESSAGES: {} + } + + this.VIDEO_IMAGE = { + VALIDATORS: [ ], + MESSAGES: {} + } + + this.VIDEO_CHANNEL = { + VALIDATORS: [ Validators.required ], + MESSAGES: { + 'required': this.i18n('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.') + } + } + + this.VIDEO_TAGS = { + 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.') + } + } + + this.VIDEO_SUPPORT = { + VALIDATORS: [ Validators.minLength(3), Validators.maxLength(500) ], + MESSAGES: { + 'minlength': this.i18n('Video support must be at least 3 characters long.'), + 'maxlength': this.i18n('Video support cannot be more than 500 characters long.') + } + } + } +} diff --git a/client/src/app/shared/forms/form-validators/video.ts b/client/src/app/shared/forms/form-validators/video.ts deleted file mode 100644 index a986243df..000000000 --- a/client/src/app/shared/forms/form-validators/video.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { Validators } from '@angular/forms' - -export const VIDEO_NAME = { - VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(120) ], - MESSAGES: { - 'required': 'Video name is required.', - 'minlength': 'Video name must be at least 3 characters long.', - 'maxlength': 'Video name cannot be more than 120 characters long.' - } -} - -export const VIDEO_PRIVACY = { - VALIDATORS: [ Validators.required ], - MESSAGES: { - 'required': 'Video privacy is required.' - } -} - -export const VIDEO_CATEGORY = { - VALIDATORS: [ ], - MESSAGES: {} -} - -export const VIDEO_LICENCE = { - VALIDATORS: [ ], - MESSAGES: {} -} - -export const VIDEO_LANGUAGE = { - VALIDATORS: [ ], - MESSAGES: {} -} - -export const VIDEO_IMAGE = { - VALIDATORS: [ ], - MESSAGES: {} -} - -export const VIDEO_CHANNEL = { - VALIDATORS: [ Validators.required ], - MESSAGES: { - 'required': 'Video channel is required.' - } -} - -export const VIDEO_DESCRIPTION = { - VALIDATORS: [ Validators.minLength(3), Validators.maxLength(10000) ], - MESSAGES: { - 'minlength': 'Video description must be at least 3 characters long.', - 'maxlength': 'Video description cannot be more than 10000 characters long.' - } -} - -export const VIDEO_TAGS = { - VALIDATORS: [ Validators.minLength(2), Validators.maxLength(30) ], - MESSAGES: { - 'minlength': 'A tag should be more than 2 characters long.', - 'maxlength': 'A tag should be less than 30 characters long.' - } -} - -export const VIDEO_SUPPORT = { - VALIDATORS: [ Validators.minLength(3), Validators.maxLength(500) ], - MESSAGES: { - 'minlength': 'Video support must be at least 3 characters long.', - 'maxlength': 'Video support cannot be more than 500 characters long.' - } -} diff --git a/client/src/app/shared/shared.module.ts b/client/src/app/shared/shared.module.ts index 91d905ec7..b85445ef5 100644 --- a/client/src/app/shared/shared.module.ts +++ b/client/src/app/shared/shared.module.ts @@ -35,6 +35,12 @@ import { AccountService } from '@app/shared/account/account.service' import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' import { I18n } from '@ngx-translate/i18n-polyfill' import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' +import { + CustomConfigValidatorsService, + LoginValidatorsService, + ResetPasswordValidatorsService, + UserValidatorsService, VideoAbuseValidatorsService, VideoChannelValidatorsService, VideoCommentValidatorsService, VideoValidatorsService +} from '@app/shared/forms' @NgModule({ imports: [ @@ -111,7 +117,17 @@ import { FormValidatorService } from '@app/shared/forms/form-validators/form-val AccountService, MarkdownService, VideoChannelService, + FormValidatorService, + CustomConfigValidatorsService, + LoginValidatorsService, + ResetPasswordValidatorsService, + UserValidatorsService, + VideoAbuseValidatorsService, + VideoChannelValidatorsService, + VideoCommentValidatorsService, + VideoValidatorsService, + I18n ] }) diff --git a/client/src/app/signup/signup.component.ts b/client/src/app/signup/signup.component.ts index 682e592c7..a40f42cb1 100644 --- a/client/src/app/signup/signup.component.ts +++ b/client/src/app/signup/signup.component.ts @@ -1,10 +1,9 @@ import { Component, OnInit } from '@angular/core' import { Router } from '@angular/router' import { ServerService } from '@app/core/server' - import { NotificationsService } from 'angular2-notifications' import { UserCreate } from '../../../../shared' -import { FormReactive, USER_EMAIL, USER_PASSWORD, USER_USERNAME, UserService } from '../shared' +import { FormReactive, UserService, UserValidatorsService } from '../shared' import { RedirectService } from '@app/core' import { I18n } from '@ngx-translate/i18n-polyfill' import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' @@ -32,6 +31,7 @@ export class SignupComponent extends FormReactive implements OnInit { constructor ( protected formValidatorService: FormValidatorService, + private userValidatorsService: UserValidatorsService, private router: Router, private notificationsService: NotificationsService, private userService: UserService, @@ -48,9 +48,9 @@ export class SignupComponent extends FormReactive implements OnInit { ngOnInit () { this.buildForm({ - username: USER_USERNAME, - password: USER_PASSWORD, - email: USER_EMAIL + username: this.userValidatorsService.USER_USERNAME, + password: this.userValidatorsService.USER_PASSWORD, + email: this.userValidatorsService.USER_EMAIL }) this.serverService.configLoaded diff --git a/client/src/app/videos/+video-edit/shared/video-edit.component.ts b/client/src/app/videos/+video-edit/shared/video-edit.component.ts index cd2a26ae3..61515c0b0 100644 --- a/client/src/app/videos/+video-edit/shared/video-edit.component.ts +++ b/client/src/app/videos/+video-edit/shared/video-edit.component.ts @@ -1,20 +1,9 @@ import { Component, Input, OnInit } from '@angular/core' -import { FormGroup } from '@angular/forms' +import { FormGroup, ValidatorFn } from '@angular/forms' import { ActivatedRoute, Router } from '@angular/router' -import { VIDEO_SUPPORT } from '@app/shared' +import { FormReactiveValidationMessages, VideoValidatorsService } from '@app/shared' import { NotificationsService } from 'angular2-notifications' import { ServerService } from '../../../core/server' -import { VIDEO_CHANNEL } from '../../../shared/forms/form-validators' -import { ValidatorMessage } from '../../../shared/forms/form-validators/validator-message' -import { - VIDEO_CATEGORY, - VIDEO_DESCRIPTION, - VIDEO_LANGUAGE, - VIDEO_LICENCE, - VIDEO_NAME, - VIDEO_PRIVACY, - VIDEO_TAGS -} from '../../../shared/forms/form-validators/video' import { VideoEdit } from '../../../shared/video/video-edit.model' import { map } from 'rxjs/operators' import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' @@ -28,7 +17,7 @@ import { FormValidatorService } from '@app/shared/forms/form-validators/form-val export class VideoEditComponent implements OnInit { @Input() form: FormGroup @Input() formErrors: { [ id: string ]: string } = {} - @Input() validationMessages: ValidatorMessage = {} + @Input() validationMessages: FormReactiveValidationMessages = {} @Input() videoPrivacies = [] @Input() userVideoChannels: { id: number, label: string, support: string }[] = [] @@ -37,18 +26,22 @@ export class VideoEditComponent implements OnInit { videoLanguages = [] video: VideoEdit - tagValidators = VIDEO_TAGS.VALIDATORS - tagValidatorsMessages = VIDEO_TAGS.MESSAGES + tagValidators: ValidatorFn[] + tagValidatorsMessages: { [ name: string ]: string } error: string = null constructor ( private formValidatorService: FormValidatorService, + private videoValidatorsService: VideoValidatorsService, private route: ActivatedRoute, private router: Router, private notificationsService: NotificationsService, private serverService: ServerService - ) { } + ) { + this.tagValidators = this.videoValidatorsService.VIDEO_TAGS.VALIDATORS + this.tagValidatorsMessages = this.videoValidatorsService.VIDEO_TAGS.MESSAGES + } updateForm () { const defaultValues = { @@ -57,19 +50,19 @@ export class VideoEditComponent implements OnInit { tags: [] } const obj = { - name: VIDEO_NAME, - privacy: VIDEO_PRIVACY, - channelId: VIDEO_CHANNEL, + name: this.videoValidatorsService.VIDEO_NAME, + privacy: this.videoValidatorsService.VIDEO_PRIVACY, + channelId: this.videoValidatorsService.VIDEO_CHANNEL, nsfw: null, commentsEnabled: null, - category: VIDEO_CATEGORY, - licence: VIDEO_LICENCE, - language: VIDEO_LANGUAGE, - description: VIDEO_DESCRIPTION, + category: this.videoValidatorsService.VIDEO_CATEGORY, + licence: this.videoValidatorsService.VIDEO_LICENCE, + language: this.videoValidatorsService.VIDEO_LANGUAGE, + description: this.videoValidatorsService.VIDEO_DESCRIPTION, tags: null, thumbnailfile: null, previewfile: null, - support: VIDEO_SUPPORT + support: this.videoValidatorsService.VIDEO_SUPPORT } this.formValidatorService.updateForm( diff --git a/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts b/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts index c70e544a3..46d7a4e9e 100644 --- a/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts +++ b/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts @@ -3,13 +3,13 @@ import { NotificationsService } from 'angular2-notifications' import { Observable } from 'rxjs' import { VideoCommentCreate } from '../../../../../../shared/models/videos/video-comment.model' import { FormReactive } from '../../../shared' -import { VIDEO_COMMENT_TEXT } from '../../../shared/forms/form-validators/video-comment' import { User } from '../../../shared/users' import { Video } from '../../../shared/video/video.model' import { VideoComment } from './video-comment.model' import { VideoCommentService } from './video-comment.service' import { I18n } from '@ngx-translate/i18n-polyfill' import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' +import { VideoCommentValidatorsService } from '@app/shared/forms/form-validators/video-comment-validators.service' @Component({ selector: 'my-video-comment-add', @@ -29,6 +29,7 @@ export class VideoCommentAddComponent extends FormReactive implements OnInit { constructor ( protected formValidatorService: FormValidatorService, + private videoCommentValidatorsService: VideoCommentValidatorsService, private notificationsService: NotificationsService, private videoCommentService: VideoCommentService, private i18n: I18n @@ -38,7 +39,7 @@ export class VideoCommentAddComponent extends FormReactive implements OnInit { ngOnInit () { this.buildForm({ - text: VIDEO_COMMENT_TEXT + text: this.videoCommentValidatorsService.VIDEO_COMMENT_TEXT }) if (this.focusOnInit === true) { diff --git a/client/src/app/videos/+video-watch/modal/video-report.component.ts b/client/src/app/videos/+video-watch/modal/video-report.component.ts index 8641e8dfb..d9768fdac 100644 --- a/client/src/app/videos/+video-watch/modal/video-report.component.ts +++ b/client/src/app/videos/+video-watch/modal/video-report.component.ts @@ -1,12 +1,11 @@ import { Component, Input, OnInit, ViewChild } from '@angular/core' -import { FormBuilder, FormGroup } from '@angular/forms' import { NotificationsService } from 'angular2-notifications' import { ModalDirective } from 'ngx-bootstrap/modal' -import { FormReactive, VIDEO_ABUSE_REASON, VideoAbuseService } from '../../../shared/index' +import { FormReactive, VideoAbuseService } from '../../../shared/index' import { VideoDetails } from '../../../shared/video/video-details.model' import { I18n } from '@ngx-translate/i18n-polyfill' -import { FormReactiveErrors, FormReactiveValidationMessages } from '@app/shared' import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' +import { VideoAbuseValidatorsService } from '@app/shared/forms/form-validators/video-abuse-validators.service' @Component({ selector: 'my-video-report', @@ -22,6 +21,7 @@ export class VideoReportComponent extends FormReactive implements OnInit { constructor ( protected formValidatorService: FormValidatorService, + private videoAbuseValidatorsService: VideoAbuseValidatorsService, private videoAbuseService: VideoAbuseService, private notificationsService: NotificationsService, private i18n: I18n @@ -31,7 +31,7 @@ export class VideoReportComponent extends FormReactive implements OnInit { ngOnInit () { this.buildForm({ - reason: VIDEO_ABUSE_REASON + reason: this.videoAbuseValidatorsService.VIDEO_ABUSE_REASON }) } diff --git a/client/src/locale/source/messages_en_US.xml b/client/src/locale/source/messages_en_US.xml index 9ac231954..08949c564 100644 --- a/client/src/locale/source/messages_en_US.xml +++ b/client/src/locale/source/messages_en_US.xml @@ -306,7 +306,7 @@ app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts - 14 + 17 app/+video-channels/video-channel-about/video-channel-about.component.ts @@ -739,8 +739,8 @@ Check this checkbox, save the configuration and test with a video URL of your in app/+admin/config/edit-custom-config/edit-custom-config.component.ts 207 - - Preview cache size + + Previews cache size app/+admin/config/edit-custom-config/edit-custom-config.component.ts 210 @@ -1239,7 +1239,7 @@ Check this checkbox, save the configuration and test with a video URL of your in app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts - 5 + 6 Short text to tell people how they can support your channel (membership platform...).<br /><br /> @@ -1296,7 +1296,7 @@ When you will upload a video in this channel, the video support field will be au Update my profile app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts - 23 + 27 @@ -1851,8 +1851,8 @@ When you will upload a video in this channel, the video support field will be au 1 - - Published <x id="INTERPOLATION" equiv-text="{{ totalVideos }}"/> videos + + Published <x id="INTERPOLATION" equiv-text="{{totalVideos}}"/> videos src/app/+accounts/account-videos/account-videos.component.ts 1 @@ -2009,8 +2009,8 @@ When you will upload a video in this channel, the video support field will be au 1 - - You set custom <x id="INTERPOLATION" equiv-text="{{ customizationsText }}"/>. + + You set custom <x id="INTERPOLATION" equiv-text="{{customizationsText}}"/>. src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts 1 @@ -2030,15 +2030,15 @@ When you will upload a video in this channel, the video support field will be au 1 - - Please type "I understand the <x id="INTERPOLATION" equiv-text="{{ customizationsText }}"/> I set" to confirm. + + Please type src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts 1 - - I understand the <x id="INTERPOLATION" equiv-text="{{ customizationsText }}"/> I set + + to confirm. src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts 1 @@ -2146,8 +2146,8 @@ When you will upload a video in this channel, the video support field will be au 1 - - <x id="INTERPOLATION" equiv-text="{{ host }}"/> is not valid + + <x id="INTERPOLATION" equiv-text="{{host}}"/> is not valid src/app/+admin/follows/following-add/following-add.component.ts 1 @@ -2188,8 +2188,8 @@ When you will upload a video in this channel, the video support field will be au 1 - - Do you really want to unfollow <x id="INTERPOLATION" equiv-text="{{ host }}"/>? + + Do you really want to unfollow <x id="INTERPOLATION" equiv-text="{{host}}"/>? src/app/+admin/follows/following-list/following-list.component.ts 1 @@ -2202,22 +2202,22 @@ When you will upload a video in this channel, the video support field will be au 1 - - You are not following <x id="INTERPOLATION" equiv-text="{{ host }}"/> anymore. + + You are not following <x id="INTERPOLATION" equiv-text="{{host}}"/> anymore. src/app/+admin/follows/following-list/following-list.component.ts 1 - - User <x id="INTERPOLATION" equiv-text="{{ username }}"/> created. + + User <x id="INTERPOLATION" equiv-text="{{username}}"/> created. src/app/+admin/users/user-edit/user-create.component.ts 1 - - User <x id="INTERPOLATION" equiv-text="{{ username }}"/> updated. + + User <x id="INTERPOLATION" equiv-text="{{username}}"/> updated. src/app/+admin/users/user-edit/user-update.component.ts 1 @@ -2244,8 +2244,8 @@ When you will upload a video in this channel, the video support field will be au 1 - - User <x id="INTERPOLATION" equiv-text="{{ username }}"/> deleted. + + User <x id="INTERPOLATION" equiv-text="{{username}}"/> deleted. src/app/+admin/users/user-list/user-list.component.ts 1 @@ -2258,8 +2258,8 @@ When you will upload a video in this channel, the video support field will be au 1 - - Video <x id="INTERPOLATION" equiv-text="{{ name }}"/> removed from the blacklist. + + Video <x id="INTERPOLATION" equiv-text="{{name}}"/> removed from the blacklist. src/app/+admin/video-blacklist/video-blacklist-list/video-blacklist-list.component.ts 1 @@ -2307,8 +2307,8 @@ When you will upload a video in this channel, the video support field will be au 1 - - Video channel <x id="INTERPOLATION" equiv-text="{{ videoChannelName }}"/> created. + + Video channel <x id="INTERPOLATION" equiv-text="{{videoChannelName}}"/> created. src/app/+my-account/my-account-video-channels/my-account-video-channel-create.component.ts 1 @@ -2321,15 +2321,15 @@ When you will upload a video in this channel, the video support field will be au 1 - - Video channel <x id="INTERPOLATION" equiv-text="{{ videoChannelName }}"/> updated. + + Video channel <x id="INTERPOLATION" equiv-text="{{videoChannelName}}"/> updated. src/app/+my-account/my-account-video-channels/my-account-video-channel-update.component.ts 1 - - Do you really want to delete <x id="INTERPOLATION" equiv-text="{{ videoChannelName }}"/>? It will delete all videos uploaded in this channel too. + + Do you really want to delete <x id="INTERPOLATION" equiv-text="{{videoChannelName}}"/>? It will delete all videos uploaded in this channel too. src/app/+my-account/my-account-video-channels/my-account-video-channels.component.ts 1 @@ -2342,8 +2342,8 @@ When you will upload a video in this channel, the video support field will be au 1 - - Video channel {{ videoChannelName } deleted. + + Video channel <x id="INTERPOLATION" equiv-text="{{videoChannelName}}"/> deleted. src/app/+my-account/my-account-video-channels/my-account-video-channels.component.ts 1 @@ -2356,8 +2356,8 @@ When you will upload a video in this channel, the video support field will be au 1 - - Cannot retrieve OAuth Client credentials: <x id="INTERPOLATION" equiv-text="{{ errorText }}"/>. + + Cannot retrieve OAuth Client credentials: <x id="INTERPOLATION" equiv-text="{{errorText}}"/>. src/app/core/auth/auth.service.ts @@ -2406,6 +2406,387 @@ When you will upload a video in this channel, the video support field will be au 1 + + Instance name is required. + + src/app/shared/forms/form-validators/custom-config-validators.service.ts + 1 + + + + Short description should not be longer than 250 characters. + + src/app/shared/forms/form-validators/custom-config-validators.service.ts + 1 + + + + Twitter username is required. + + src/app/shared/forms/form-validators/custom-config-validators.service.ts + 1 + + + + Previews cache size is required. + + src/app/shared/forms/form-validators/custom-config-validators.service.ts + 1 + + + + Previews cache size must be greater than 1. + + src/app/shared/forms/form-validators/custom-config-validators.service.ts + 1 + + + + Previews cache size must be a number. + + src/app/shared/forms/form-validators/custom-config-validators.service.ts + 1 + + + + Signup limit is required. + + src/app/shared/forms/form-validators/custom-config-validators.service.ts + 1 + + + + Signup limit must be greater than 1. + + src/app/shared/forms/form-validators/custom-config-validators.service.ts + 1 + + + + Signup limit must be a number. + + src/app/shared/forms/form-validators/custom-config-validators.service.ts + 1 + + + + Admin email is required. + + src/app/shared/forms/form-validators/custom-config-validators.service.ts + 1 + + + + Admin email must be valid. + + src/app/shared/forms/form-validators/custom-config-validators.service.ts + 1 + + + + Transcoding threads is required. + + src/app/shared/forms/form-validators/custom-config-validators.service.ts + 1 + + + + Transcoding threads must be greater than 1. + + src/app/shared/forms/form-validators/custom-config-validators.service.ts + 1 + + + + Username is required. + + src/app/shared/forms/form-validators/login-validators.service.ts + 1 + + + src/app/shared/forms/form-validators/user-validators.service.ts + 1 + + + + Password is required. + + src/app/shared/forms/form-validators/login-validators.service.ts + 1 + + + src/app/shared/forms/form-validators/user-validators.service.ts + 1 + + + + Confirmation of the password is required. + + src/app/shared/forms/form-validators/reset-password-validators.service.ts + 1 + + + + Username must be at least 3 characters long. + + src/app/shared/forms/form-validators/user-validators.service.ts + 1 + + + + Username cannot be more than 20 characters long. + + src/app/shared/forms/form-validators/user-validators.service.ts + 1 + + + + Username should be only lowercase alphanumeric characters. + + src/app/shared/forms/form-validators/user-validators.service.ts + 1 + + + + Email is required. + + src/app/shared/forms/form-validators/user-validators.service.ts + 1 + + + + Email must be valid. + + src/app/shared/forms/form-validators/user-validators.service.ts + 1 + + + + Password must be at least 6 characters long. + + src/app/shared/forms/form-validators/user-validators.service.ts + 1 + + + + Password cannot be more than 255 characters long. + + src/app/shared/forms/form-validators/user-validators.service.ts + 1 + + + + Video quota is required. + + src/app/shared/forms/form-validators/user-validators.service.ts + 1 + + + + Quota must be greater than -1. + + src/app/shared/forms/form-validators/user-validators.service.ts + 1 + + + + User role is required. + + src/app/shared/forms/form-validators/user-validators.service.ts + 1 + + + + Display name is required. + + src/app/shared/forms/form-validators/user-validators.service.ts + 1 + + + src/app/shared/forms/form-validators/video-channel-validators.service.ts + 1 + + + + Display name must be at least 3 characters long. + + src/app/shared/forms/form-validators/user-validators.service.ts + 1 + + + src/app/shared/forms/form-validators/video-channel-validators.service.ts + 1 + + + + Display name cannot be more than 120 characters long. + + src/app/shared/forms/form-validators/user-validators.service.ts + 1 + + + src/app/shared/forms/form-validators/video-channel-validators.service.ts + 1 + + + + Description must be at least 3 characters long. + + src/app/shared/forms/form-validators/user-validators.service.ts + 1 + + + src/app/shared/forms/form-validators/video-channel-validators.service.ts + 1 + + + + Description cannot be more than 250 characters long. + + src/app/shared/forms/form-validators/user-validators.service.ts + 1 + + + + Report reason is required. + + src/app/shared/forms/form-validators/video-abuse-validators.service.ts + 1 + + + + Report reason must be at least 2 characters long. + + src/app/shared/forms/form-validators/video-abuse-validators.service.ts + 1 + + + + Report reason cannot be more than 300 characters long. + + src/app/shared/forms/form-validators/video-abuse-validators.service.ts + 1 + + + + Description cannot be more than 500 characters long. + + src/app/shared/forms/form-validators/video-channel-validators.service.ts + 1 + + + + Support text must be at least 3 characters long. + + src/app/shared/forms/form-validators/video-channel-validators.service.ts + 1 + + + + Support text cannot be more than 500 characters long. + + src/app/shared/forms/form-validators/video-channel-validators.service.ts + 1 + + + + Comment is required. + + src/app/shared/forms/form-validators/video-comment-validators.service.ts + 1 + + + + Comment must be at least 2 characters long. + + src/app/shared/forms/form-validators/video-comment-validators.service.ts + 1 + + + + Comment cannot be more than 3000 characters long. + + src/app/shared/forms/form-validators/video-comment-validators.service.ts + 1 + + + + Video name is required. + + src/app/shared/forms/form-validators/video-validators.service.ts + 1 + + + + Video name must be at least 3 characters long. + + src/app/shared/forms/form-validators/video-validators.service.ts + 1 + + + + Video name cannot be more than 120 characters long. + + src/app/shared/forms/form-validators/video-validators.service.ts + 1 + + + + Video privacy is required. + + src/app/shared/forms/form-validators/video-validators.service.ts + 1 + + + + Video channel is required. + + src/app/shared/forms/form-validators/video-validators.service.ts + 1 + + + + Video description must be at least 3 characters long. + + src/app/shared/forms/form-validators/video-validators.service.ts + 1 + + + + Video description cannot be more than 10000 characters long. + + src/app/shared/forms/form-validators/video-validators.service.ts + 1 + + + + A tag should be more than 2 characters long. + + src/app/shared/forms/form-validators/video-validators.service.ts + 1 + + + + A tag should be less than 30 characters long. + + src/app/shared/forms/form-validators/video-validators.service.ts + 1 + + + + Video support must be at least 3 characters long. + + src/app/shared/forms/form-validators/video-validators.service.ts + 1 + + + + Video support cannot be more than 500 characters long. + + src/app/shared/forms/form-validators/video-validators.service.ts + 1 + + All unsaved data will be lost, are you sure you want to leave this page? @@ -2420,78 +2801,78 @@ When you will upload a video in this channel, the video support field will be au 1 - - <x id="INTERPOLATION" equiv-text="{{ interval }}"/> years ago + + <x id="INTERPOLATION" equiv-text="{{interval}}"/> years ago src/app/shared/misc/from-now.pipe.ts 1 - - <x id="INTERPOLATION" equiv-text="{{ interval }}"/> months ago + + <x id="INTERPOLATION" equiv-text="{{interval}}"/> months ago src/app/shared/misc/from-now.pipe.ts 1 - - <x id="INTERPOLATION" equiv-text="{{ interval }}"/> month ago + + <x id="INTERPOLATION" equiv-text="{{interval}}"/> month ago src/app/shared/misc/from-now.pipe.ts 1 - - <x id="INTERPOLATION" equiv-text="{{ interval }}"/> weeks ago + + <x id="INTERPOLATION" equiv-text="{{interval}}"/> weeks ago src/app/shared/misc/from-now.pipe.ts 1 - - <x id="INTERPOLATION" equiv-text="{{ interval }}"/> week ago + + <x id="INTERPOLATION" equiv-text="{{interval}}"/> week ago src/app/shared/misc/from-now.pipe.ts 1 - - <x id="INTERPOLATION" equiv-text="{{ interval }}"/> days ago + + <x id="INTERPOLATION" equiv-text="{{interval}}"/> days ago src/app/shared/misc/from-now.pipe.ts 1 - - <x id="INTERPOLATION" equiv-text="{{ interval }}"/> day ago + + <x id="INTERPOLATION" equiv-text="{{interval}}"/> day ago src/app/shared/misc/from-now.pipe.ts 1 - - <x id="INTERPOLATION" equiv-text="{{ interval }}"/> hours ago + + <x id="INTERPOLATION" equiv-text="{{interval}}"/> hours ago src/app/shared/misc/from-now.pipe.ts 1 - - <x id="INTERPOLATION" equiv-text="{{ interval }}"/> hour ago + + <x id="INTERPOLATION" equiv-text="{{interval}}"/> hour ago src/app/shared/misc/from-now.pipe.ts 1 - - <x id="INTERPOLATION" equiv-text="{{ interval }}"/> min ago + + <x id="INTERPOLATION" equiv-text="{{interval}}"/> min ago src/app/shared/misc/from-now.pipe.ts 1 - - <x id="INTERPOLATION" equiv-text="{{ interval }}"/> sec ago + + <x id="INTERPOLATION" equiv-text="{{interval}}"/> sec ago src/app/shared/misc/from-now.pipe.ts 1 @@ -2504,8 +2885,8 @@ When you will upload a video in this channel, the video support field will be au 1 - - Too many attempts, please try again after <x id="INTERPOLATION" equiv-text="{{ minutesLeft }}"/> minutes. + + Too many attempts, please try again after <x id="INTERPOLATION" equiv-text="{{minutesLeft}}"/> minutes. src/app/shared/rest/rest-extractor.service.ts 1 @@ -2525,29 +2906,29 @@ When you will upload a video in this channel, the video support field will be au 1 - - Registration for <x id="INTERPOLATION" equiv-text="{{ username }}"/> complete. + + Registration for <x id="INTERPOLATION" equiv-text="{{username}}"/> complete. src/app/signup/signup.component.ts 1 - - <x id="INTERPOLATION" equiv-text="{{ seconds }}"/> of full HD videos + + <x id="INTERPOLATION" equiv-text="{{seconds}}"/> of full HD videos src/app/signup/signup.component.ts 1 - - <x id="INTERPOLATION" equiv-text="{{ seconds }}"/> of HD videos + + <x id="INTERPOLATION" equiv-text="{{seconds}}"/> of HD videos src/app/signup/signup.component.ts 1 - - <x id="INTERPOLATION" equiv-text="{{ seconds }}"/> of average quality videos + + <x id="INTERPOLATION" equiv-text="{{seconds}}"/> of average quality videos src/app/signup/signup.component.ts 1 @@ -2616,8 +2997,8 @@ When you will upload a video in this channel, the video support field will be au 1 - - <x id="INTERPOLATION" equiv-text="{{ totalReplies }}"/> replies will be deleted too. + + <x id="INTERPOLATION" equiv-text="{{totalReplies}}"/> replies will be deleted too. src/app/videos/+video-watch/comment/video-comments.component.ts 1 @@ -2644,8 +3025,8 @@ When you will upload a video in this channel, the video support field will be au 1 - - Video <x id="INTERPOLATION" equiv-text="{{ videoName }}"/> had been blacklisted. + + Video <x id="INTERPOLATION" equiv-text="{{videoName}}"/> had been blacklisted. src/app/videos/+video-watch/video-watch.component.ts 1 @@ -2658,15 +3039,15 @@ When you will upload a video in this channel, the video support field will be au 1 - - Video <x id="INTERPOLATION" equiv-text="{{ videoName }}"/> deleted. + + Video <x id="INTERPOLATION" equiv-text="{{videoName}}"/> deleted. src/app/videos/+video-watch/video-watch.component.ts 1 - - <x id="INTERPOLATION" equiv-text="{{ likesNumber }}"/> likes / <x id="INTERPOLATION_1" equiv-text="{{ dislikesNumber }}"/> dislikes + + <x id="INTERPOLATION" equiv-text="{{likesNumber}}"/> likes / <x id="INTERPOLATION_1" equiv-text="{{dislikesNumber}}"/> dislikes src/app/videos/+video-watch/video-watch.component.ts 1 diff --git a/client/src/locale/target/messages_fr.xml b/client/src/locale/target/messages_fr.xml index 18c9f64a7..e3c052446 100644 --- a/client/src/locale/target/messages_fr.xml +++ b/client/src/locale/target/messages_fr.xml @@ -630,9 +630,9 @@ Cochez cette case, sauvegardez la configuration et testez avec l'URL d'une vidé 207 - - Preview cache size - Taille du cache de l'aperçu + + Previews cache size + Taille du cache des prévisualisations 210 @@ -1117,7 +1117,7 @@ Cochez cette case, sauvegardez la configuration et testez avec l'URL d'une vidé Display name Nom public - 5 + 6 @@ -1175,7 +1175,7 @@ Quand vous mettrez en ligne une vidéo sur cette chaîne, la vidéo affichera au Update my profile Mettre à jour mon profil - 23 + 27 @@ -1793,9 +1793,9 @@ Quand vous mettrez en ligne une vidéo sur cette chaîne, la vidéo affichera au 1 - - Published videos - A publié vidéos + + Published videos + A publié vidéos 1 @@ -1807,9 +1807,9 @@ Quand vous mettrez en ligne une vidéo sur cette chaîne, la vidéo affichera au 1 - - You set custom . - Vous avez paramétré . + + You set custom . + Vous avez défini du . 1 @@ -1828,16 +1828,16 @@ Quand vous mettrez en ligne une vidéo sur cette chaîne, la vidéo affichera au 1 - - Please type "I understand the I set" to confirm. - Merci d'écrire "Je comprends avoir rentré <x id="INTERPOLATION" equiv-text="{{ customizationsText }}"/>" pour confirmer votre choix. + + Please type + Merci de taper 1 - - I understand the I set - Je comprends avoir rentré + + to confirm. + pour confirmer. 1 @@ -1856,9 +1856,9 @@ Quand vous mettrez en ligne une vidéo sur cette chaîne, la vidéo affichera au 1 - - is not valid - n'est pas un hôte valide + + is not valid + n'est pas valide 1 @@ -1898,9 +1898,9 @@ Quand vous mettrez en ligne une vidéo sur cette chaîne, la vidéo affichera au 1 - - Do you really want to unfollow ? - Souhaitez-vous vraiment arrêter de suivre ? + + Do you really want to unfollow ? + Voulez-vous vraiment vous désabonner de ? 1 @@ -1912,23 +1912,23 @@ Quand vous mettrez en ligne une vidéo sur cette chaîne, la vidéo affichera au 1 - - You are not following anymore. - Vous ne suivez plus . + + You are not following anymore. + Vous n'êtes plus abonné à . 1 - - User created. - Utilisateur créé. + + User created. + Utilisateur créé. 1 - - User updated. - Utilisateur mis à jour. + + User updated. + Utilisateur mis à jour. 1 @@ -1954,9 +1954,9 @@ Quand vous mettrez en ligne une vidéo sur cette chaîne, la vidéo affichera au 1 - - User deleted. - Utilisateur supprimé. + + User deleted. + Utilisateur supprimé. 1 @@ -1968,9 +1968,9 @@ Quand vous mettrez en ligne une vidéo sur cette chaîne, la vidéo affichera au 1 - - Video removed from the blacklist. - La vidéo a bien été enlevée de la liste noire. + + Video removed from the blacklist. + Vidéo supprimée de la liste noire. 1 @@ -2017,9 +2017,9 @@ Quand vous mettrez en ligne une vidéo sur cette chaîne, la vidéo affichera au 1 - - Video channel created. - Chaîne vidéo créée. + + Video channel created. + Chaîne vidéo créée. 1 @@ -2031,16 +2031,16 @@ Quand vous mettrez en ligne une vidéo sur cette chaîne, la vidéo affichera au 1 - - Video channel updated. - Chaîne vidéo mise à jour. + + Video channel updated. + Chaîne vidéo mise à jour. 1 - - Do you really want to delete ? It will delete all videos uploaded in this channel too. - Êtes-vous bien sûr de vouloir supprimer ? Cette action aura aussi pour effet de supprimer toutes les vidéos ayant appartenu à cette chaîne. + + Do you really want to delete ? It will delete all videos uploaded in this channel too. + Voulez-vous vraiment supprimer ? Ceci supprimera aussi toutes les vidéos téléversées dans cette chaîne. 1 @@ -2052,9 +2052,9 @@ Quand vous mettrez en ligne une vidéo sur cette chaîne, la vidéo affichera au 1 - - Video channel {{ videoChannelName } deleted. - Chaîne vidéo {{ videoChannelName } supprimée. + + Video channel deleted. + Chaîne vidéo supprimée. 1 @@ -2066,10 +2066,10 @@ Quand vous mettrez en ligne une vidéo sur cette chaîne, la vidéo affichera au 1 - - Cannot retrieve OAuth Client credentials: . + + Cannot retrieve OAuth Client credentials: . - Impossible de récupérer les identifiants Client OAuth : . + Impossible de retrouver les identifiants client OAuth : . 1 @@ -2117,6 +2117,363 @@ Quand vous mettrez en ligne une vidéo sur cette chaîne, la vidéo affichera au 1 + + Instance name is required. + Le nom de l'instance est requis. + + 1 + + + + Short description should not be longer than 250 characters. + La courte description ne peut pas faire plus de 250 caractères. + + 1 + + + + Twitter username is required. + L'identifiant Twitter est requis. + + 1 + + + + Previews cache size is required. + La taille du cache des prévisualisations est requis. + + 1 + + + + Previews cache size must be greater than 1. + La taille du cache des prévisualisations doit être plus grand que 1. + + 1 + + + + Previews cache size must be a number. + La taille du cache des prévisualisations doit être un nombre. + + 1 + + + + Signup limit is required. + La limite d'enregistrements est requis. + + 1 + + + + Signup limit must be greater than 1. + La limite d'enregistrement doit faire plus de 1. + + 1 + + + + Signup limit must be a number. + La limite d'enregistrement doit être un nombre. + + 1 + + + + Admin email is required. + L'email de l'administrateur est requis. + + 1 + + + + Admin email must be valid. + L'email de l'administrateur doit être valide + + 1 + + + + Transcoding threads is required. + Le nombre de threads pour l'encodage est requis. + + 1 + + + + Transcoding threads must be greater than 1. + Le nombre de threads pour l'encodage doit être plus grand que 1. + + 1 + + + + Username is required. + Le nom d'utilisateur est requis. + + 1 + + + + Password is required. + Le mot de passe est requis. + + 1 + + + + Confirmation of the password is required. + La confirmation du mot de passe est requis. + + 1 + + + + Username must be at least 3 characters long. + Le nom d'utilisateur doit être composé d'au moins 3 caractères. + + 1 + + + + Username cannot be more than 20 characters long. + Le nom d'utilisateur ne peut pas faire plus de 20 caractères. + + 1 + + + + Username should be only lowercase alphanumeric characters. + Le nom d'utilisateur ne doit être composé que de caractères alphnumériques en minuscule. + + 1 + + + + Email is required. + L'email est requis. + + 1 + + + + Email must be valid. + L'email doit être valide. + + 1 + + + + Password must be at least 6 characters long. + Le mot de passe doit être composé d'au moins 6 caractères. + + 1 + + + + Password cannot be more than 255 characters long. + Le mot de passe ne peut pas faire plus de 255 caractères. + + 1 + + + + Video quota is required. + Le quota de vidéos est requis. + + 1 + + + + Quota must be greater than -1. + Le quota doit être plus grand que -1. + + 1 + + + + User role is required. + Le rôle utilisateur est requis. + + 1 + + + + Display name is required. + Le nom d'affichage est requis. + + 1 + + + + Display name must be at least 3 characters long. + Le nom d'affichage doit être composé d'au moins 3 caractères. + + 1 + + + + Display name cannot be more than 120 characters long. + Le nom d'affichage ne peut pas faire plus de 120 caractères. + + 1 + + + + Description must be at least 3 characters long. + La description doit être composé d'au moins 3 caractères. + + 1 + + + + Description cannot be more than 250 characters long. + La description ne peut pas faire plus de 250 caractères. + + 1 + + + + Report reason is required. + La raison du signalement est requise. + + 1 + + + + Report reason must be at least 2 characters long. + La raison du signalement doit être composé d'au moins 2 caractères. + + 1 + + + + Report reason cannot be more than 300 characters long. + La raison du signalement ne peut pas faire plus de 300 caractères. + + 1 + + + + Description cannot be more than 500 characters long. + La description ne peut pas faire plus de 500 caractères. + + 1 + + + + Support text must be at least 3 characters long. + Le texte de support doit être composé d'au moins 3 caractères. + + 1 + + + + Support text cannot be more than 500 characters long. + Le texte du support ne peut pas faire plus de 500 caractères. + + 1 + + + + Comment is required. + Le commentaire est requis. + + 1 + + + + Comment must be at least 2 characters long. + Le commentaire doit être composé d'au moins 2 caractères. + + 1 + + + + Comment cannot be more than 3000 characters long. + Le commentaire ne peut pas faire plus de 3000 caractères. + + 1 + + + + Video name is required. + Le nom de la vidéo est requis. + + 1 + + + + Video name must be at least 3 characters long. + Le nom de la vidéo doit faire au moins 3 caractères. + + 1 + + + + Video name cannot be more than 120 characters long. + Le nom de la vidéo ne doit pas faire plus de 120 caractères. + + 1 + + + + Video privacy is required. + La confidentialité de la vidéo est requise. + + 1 + + + + Video channel is required. + La chaîne de la vidéo est requise. + + 1 + + + + Video description must be at least 3 characters long. + La description de la vidéo doit faire au moins 3 caractères. + + 1 + + + + Video description cannot be more than 10000 characters long. + La description de la vidéo ne peut pas faire plus de 10000 caractères. + + 1 + + + + A tag should be more than 2 characters long. + Une étiquette doit faire au moins 2 caractères. + + 1 + + + + A tag should be less than 30 characters long. + Une étiquette ne peut pas faire plus de 30 caractères. + + 1 + + + + Video support must be at least 3 characters long. + Le texte de support de la vidéo doit faire au moins 3 caractères. + + 1 + + + + Video support cannot be more than 500 characters long. + Le texte de support de la vidéo ne peut pas faire plus de 500 caractères. + + 1 + + All unsaved data will be lost, are you sure you want to leave this page? Toutes les données non sauvegardées seront perdues ; êtes-vous bien sûr·e de quitter cette page ? @@ -2131,79 +2488,79 @@ Quand vous mettrez en ligne une vidéo sur cette chaîne, la vidéo affichera au 1 - - years ago - il y a ans + + years ago + il y a ans 1 - - months ago - il y a mois + + months ago + il y a mois 1 - - month ago - il y a mois + + month ago + il y a mois 1 - - weeks ago - il y a semaines + + weeks ago + il y a semaines 1 - - week ago - il y a semaines + + week ago + il y a semaine 1 - - days ago - il y a jours + + days ago + il y a jours 1 - - day ago - il y a jour + + day ago + il y a jour 1 - - hours ago - il y a heures + + hours ago + il y a heures 1 - - hour ago - il y a heure + + hour ago + il y a heure 1 - - min ago - il y a min + + min ago + il y a min 1 - - sec ago - il y a sec + + sec ago + il y a sec 1 @@ -2215,9 +2572,9 @@ Quand vous mettrez en ligne une vidéo sur cette chaîne, la vidéo affichera au 1 - - Too many attempts, please try again after minutes. - Trop d'essais ; merci de réitérer après minutes. + + Too many attempts, please try again after minutes. + Trop de tentatives, merci de réessayer dans minutes. 1 @@ -2236,30 +2593,30 @@ Quand vous mettrez en ligne une vidéo sur cette chaîne, la vidéo affichera au 1 - - Registration for complete. - Inscription faite pour . + + Registration for complete. + Enregistrement pour complété. 1 - - of full HD videos - de vidéos en Full HD + + of full HD videos + de vidéos full HD 1 - - of HD videos - de vidéos en HD + + of HD videos + de vidéos HD 1 - - of average quality videos - de vidéos de qualité moyenne + + of average quality videos + de vidéos de qualité moyenne 1 @@ -2327,9 +2684,9 @@ Quand vous mettrez en ligne une vidéo sur cette chaîne, la vidéo affichera au 1 - - replies will be deleted too. - commentaires seront aussi supprimés. + + replies will be deleted too. + réponses seront aussi supprimées. 1 @@ -2355,9 +2712,9 @@ Quand vous mettrez en ligne une vidéo sur cette chaîne, la vidéo affichera au 1 - - Video had been blacklisted. - La vidéo a bien été mise sur liste noire. + + Video had been blacklisted. + La vidéo a été mise sur liste noire. 1 @@ -2369,16 +2726,16 @@ Quand vous mettrez en ligne une vidéo sur cette chaîne, la vidéo affichera au 1 - - Video deleted. - La vidéo a été supprimée. + + Video deleted. + La vidéo a été supprimée. 1 - - likes / dislikes - likes / dislikes + + likes / dislikes + j'aime / je n'aime pas 1 diff --git a/client/src/main.ts b/client/src/main.ts index e1a69e4a4..85c4c0672 100644 --- a/client/src/main.ts +++ b/client/src/main.ts @@ -1,4 +1,4 @@ -import { enableProdMode } from '@angular/core' +import { enableProdMode, TRANSLATIONS, TRANSLATIONS_FORMAT } from '@angular/core' import { platformBrowserDynamic } from '@angular/platform-browser-dynamic' import { AppModule } from './app/app.module' @@ -6,12 +6,22 @@ import { environment } from './environments/environment' import { hmrBootstrap } from './hmr' +let providers = [] if (environment.production) { enableProdMode() } +if (environment.production === false && window.location.search === '?lang=fr') { + const translations = require(`raw-loader!./locale/target/messages_fr.xml`) + + providers = [ + { provide: TRANSLATIONS, useValue: translations }, + { provide: TRANSLATIONS_FORMAT, useValue: 'xlf' } + ] +} + const bootstrap = () => platformBrowserDynamic() - .bootstrapModule(AppModule) + .bootstrapModule(AppModule, { providers }) .then(bootstrapModule => { // TODO: Uncomment and remove unregistration when https://github.com/angular/angular/issues/21191 is fixed // TODO: Remove when https://github.com/angular/angular-cli/issues/8779 is fixed?