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 --- .../my-account-videos/my-account-videos.component.ts | 17 +++++++---------- .../video-change-ownership.component.ts | 8 +++----- 2 files changed, 10 insertions(+), 15 deletions(-) (limited to 'client/src/app/+my-account/my-account-videos') diff --git a/client/src/app/+my-account/my-account-videos/my-account-videos.component.ts b/client/src/app/+my-account/my-account-videos/my-account-videos.component.ts index 2274c6a7b..46a02a41a 100644 --- a/client/src/app/+my-account/my-account-videos/my-account-videos.component.ts +++ b/client/src/app/+my-account/my-account-videos/my-account-videos.component.ts @@ -7,7 +7,6 @@ import { DisableForReuseHook } from '@app/core/routing/disable-for-reuse-hook' import { immutableAssign } from '@app/helpers' import { Video, VideoService } from '@app/shared/shared-main' import { MiniatureDisplayOptions, OwnerDisplayType, SelectionType, VideosSelectionComponent } from '@app/shared/shared-video-miniature' -import { I18n } from '@ngx-translate/i18n-polyfill' import { VideoSortField } from '@shared/models' import { VideoChangeOwnershipComponent } from './video-change-ownership/video-change-ownership.component' @@ -50,11 +49,10 @@ export class MyAccountVideosComponent implements OnInit, DisableForReuseHook { protected authService: AuthService, protected notifier: Notifier, protected screenService: ScreenService, - private i18n: I18n, private confirmService: ConfirmService, private videoService: VideoService ) { - this.titlePage = this.i18n('My videos') + this.titlePage = $localize`My videos` } ngOnInit () { @@ -97,8 +95,8 @@ export class MyAccountVideosComponent implements OnInit, DisableForReuseHook { .map(k => parseInt(k, 10)) const res = await this.confirmService.confirm( - this.i18n('Do you really want to delete {{deleteLength}} videos?', { deleteLength: toDeleteVideosIds.length }), - this.i18n('Delete') + $localize`Do you really want to delete ${toDeleteVideosIds.length} videos?`, + $localize`Delete` ) if (res === false) return @@ -114,8 +112,7 @@ export class MyAccountVideosComponent implements OnInit, DisableForReuseHook { .pipe(toArray()) .subscribe( () => { - this.notifier.success(this.i18n('{{deleteLength}} videos deleted.', { deleteLength: toDeleteVideosIds.length })) - + this.notifier.success($localize`${toDeleteVideosIds.length} videos deleted.`) this.selection = {} }, @@ -125,15 +122,15 @@ export class MyAccountVideosComponent implements OnInit, DisableForReuseHook { async deleteVideo (video: Video) { const res = await this.confirmService.confirm( - this.i18n('Do you really want to delete {{videoName}}?', { videoName: video.name }), - this.i18n('Delete') + $localize`Do you really want to delete ${video.name}?`, + $localize`Delete` ) if (res === false) return this.videoService.removeVideo(video.id) .subscribe( () => { - this.notifier.success(this.i18n('Video {{videoName}} deleted.', { videoName: video.name })) + this.notifier.success($localize`Video ${video.name} deleted.`) this.removeVideoFromArray(video.id) }, diff --git a/client/src/app/+my-account/my-account-videos/video-change-ownership/video-change-ownership.component.ts b/client/src/app/+my-account/my-account-videos/video-change-ownership/video-change-ownership.component.ts index 18e716a09..edd691694 100644 --- a/client/src/app/+my-account/my-account-videos/video-change-ownership/video-change-ownership.component.ts +++ b/client/src/app/+my-account/my-account-videos/video-change-ownership/video-change-ownership.component.ts @@ -3,7 +3,6 @@ import { Notifier, UserService } from '@app/core' import { FormReactive, FormValidatorService, VideoChangeOwnershipValidatorsService } from '@app/shared/shared-forms' import { Video, VideoOwnershipService } from '@app/shared/shared-main' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' -import { I18n } from '@ngx-translate/i18n-polyfill' @Component({ selector: 'my-video-change-ownership', @@ -25,9 +24,8 @@ export class VideoChangeOwnershipComponent extends FormReactive implements OnIni private videoOwnershipService: VideoOwnershipService, private notifier: Notifier, private userService: UserService, - private modalService: NgbModal, - private i18n: I18n - ) { + private modalService: NgbModal + ) { super() } @@ -63,7 +61,7 @@ export class VideoChangeOwnershipComponent extends FormReactive implements OnIni this.videoOwnershipService .changeOwnership(this.video.id, username) .subscribe( - () => this.notifier.success(this.i18n('Ownership change request sent.')), + () => this.notifier.success($localize`Ownership change request sent.`), err => this.notifier.error(err.message) ) -- cgit v1.2.3