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 --- .../follows/followers-list/followers-list.component.ts | 16 +++++++--------- .../follows/following-list/following-list.component.ts | 14 ++++++-------- .../follows/shared/redundancy-checkbox.component.ts | 10 ++++------ .../video-redundancies-list.component.ts | 14 ++++++-------- 4 files changed, 23 insertions(+), 31 deletions(-) (limited to 'client/src/app/+admin/follows') diff --git a/client/src/app/+admin/follows/followers-list/followers-list.component.ts b/client/src/app/+admin/follows/followers-list/followers-list.component.ts index 63135f898..904e3c338 100644 --- a/client/src/app/+admin/follows/followers-list/followers-list.component.ts +++ b/client/src/app/+admin/follows/followers-list/followers-list.component.ts @@ -2,7 +2,6 @@ import { SortMeta } from 'primeng/api' import { Component, OnInit } from '@angular/core' import { ConfirmService, Notifier, RestPagination, RestTable } from '@app/core' import { InstanceFollowService } from '@app/shared/shared-instance' -import { I18n } from '@ngx-translate/i18n-polyfill' import { ActorFollow } from '@shared/models' @Component({ @@ -19,7 +18,6 @@ export class FollowersListComponent extends RestTable implements OnInit { constructor ( private confirmService: ConfirmService, private notifier: Notifier, - private i18n: I18n, private followService: InstanceFollowService ) { super() @@ -40,7 +38,7 @@ export class FollowersListComponent extends RestTable implements OnInit { .subscribe( () => { const handle = follow.follower.name + '@' + follow.follower.host - this.notifier.success(this.i18n('{{handle}} accepted in instance followers', { handle })) + this.notifier.success($localize`${handle} accepted in instance followers`) }, err => { @@ -51,15 +49,15 @@ export class FollowersListComponent extends RestTable implements OnInit { } async rejectFollower (follow: ActorFollow) { - const message = this.i18n('Do you really want to reject this follower?') - const res = await this.confirmService.confirm(message, this.i18n('Reject')) + const message = $localize`Do you really want to reject this follower?` + const res = await this.confirmService.confirm(message, $localize`Reject`) if (res === false) return this.followService.rejectFollower(follow) .subscribe( () => { const handle = follow.follower.name + '@' + follow.follower.host - this.notifier.success(this.i18n('{{handle}} rejected from instance followers', { handle })) + this.notifier.success($localize`${handle} rejected from instance followers`) this.loadData() }, @@ -72,15 +70,15 @@ export class FollowersListComponent extends RestTable implements OnInit { } async deleteFollower (follow: ActorFollow) { - const message = this.i18n('Do you really want to delete this follower?') - const res = await this.confirmService.confirm(message, this.i18n('Delete')) + const message = $localize`Do you really want to delete this follower?` + const res = await this.confirmService.confirm(message, $localize`Delete`) if (res === false) return this.followService.removeFollower(follow) .subscribe( () => { const handle = follow.follower.name + '@' + follow.follower.host - this.notifier.success(this.i18n('{{handle}} removed from instance followers', { handle })) + this.notifier.success($localize`${handle} removed from instance followers`) this.loadData() }, diff --git a/client/src/app/+admin/follows/following-list/following-list.component.ts b/client/src/app/+admin/follows/following-list/following-list.component.ts index dae8923b5..5f71f1238 100644 --- a/client/src/app/+admin/follows/following-list/following-list.component.ts +++ b/client/src/app/+admin/follows/following-list/following-list.component.ts @@ -3,7 +3,6 @@ import { Component, OnInit, ViewChild } from '@angular/core' import { ConfirmService, Notifier, RestPagination, RestTable } from '@app/core' import { InstanceFollowService } from '@app/shared/shared-instance' import { BatchDomainsModalComponent } from '@app/shared/shared-moderation' -import { I18n } from '@ngx-translate/i18n-polyfill' import { ActorFollow } from '@shared/models' @Component({ @@ -22,9 +21,8 @@ export class FollowingListComponent extends RestTable implements OnInit { constructor ( private notifier: Notifier, private confirmService: ConfirmService, - private followService: InstanceFollowService, - private i18n: I18n - ) { + private followService: InstanceFollowService + ) { super() } @@ -47,7 +45,7 @@ export class FollowingListComponent extends RestTable implements OnInit { async addFollowing (hosts: string[]) { this.followService.follow(hosts).subscribe( () => { - this.notifier.success(this.i18n('Follow request(s) sent!')) + this.notifier.success($localize`Follow request(s) sent!`) this.loadData() }, @@ -57,14 +55,14 @@ export class FollowingListComponent extends RestTable implements OnInit { async removeFollowing (follow: ActorFollow) { const res = await this.confirmService.confirm( - this.i18n('Do you really want to unfollow {{host}}?', { host: follow.following.host }), - this.i18n('Unfollow') + $localize`Do you really want to unfollow ${follow.following.host}?`, + $localize`Unfollow` ) if (res === false) return this.followService.unfollow(follow).subscribe( () => { - this.notifier.success(this.i18n('You are not following {{host}} anymore.', { host: follow.following.host })) + this.notifier.success($localize`You are not following ${follow.following.host} anymore.`) this.loadData() }, diff --git a/client/src/app/+admin/follows/shared/redundancy-checkbox.component.ts b/client/src/app/+admin/follows/shared/redundancy-checkbox.component.ts index 662143abc..729b7f599 100644 --- a/client/src/app/+admin/follows/shared/redundancy-checkbox.component.ts +++ b/client/src/app/+admin/follows/shared/redundancy-checkbox.component.ts @@ -1,7 +1,6 @@ import { Component, Input } from '@angular/core' import { Notifier } from '@app/core' import { RedundancyService } from '@app/shared/shared-main' -import { I18n } from '@ngx-translate/i18n-polyfill' @Component({ selector: 'my-redundancy-checkbox', @@ -14,17 +13,16 @@ export class RedundancyCheckboxComponent { constructor ( private notifier: Notifier, - private redundancyService: RedundancyService, - private i18n: I18n - ) { } + private redundancyService: RedundancyService + ) { } updateRedundancyState () { this.redundancyService.updateRedundancy(this.host, this.redundancyAllowed) .subscribe( () => { - const stateLabel = this.redundancyAllowed ? this.i18n('enabled') : this.i18n('disabled') + const stateLabel = this.redundancyAllowed ? $localize`enabled` : $localize`disabled` - this.notifier.success(this.i18n('Redundancy for {{host}} is {{stateLabel}}', { host: this.host, stateLabel })) + this.notifier.success($localize`Redundancy for ${this.host} is ${stateLabel}`) }, err => this.notifier.error(err.message) diff --git a/client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.ts b/client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.ts index 07e2e0ff3..d6fd1a1ab 100644 --- a/client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.ts +++ b/client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.ts @@ -2,7 +2,6 @@ import { SortMeta } from 'primeng/api' import { Component, OnInit } from '@angular/core' import { ConfirmService, Notifier, RestPagination, RestTable, ServerService } from '@app/core' import { BytesPipe, RedundancyService } from '@app/shared/shared-main' -import { I18n } from '@ngx-translate/i18n-polyfill' import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' import { VideoRedundanciesTarget, VideoRedundancy } from '@shared/models' import { VideosRedundancyStats } from '@shared/models/server' @@ -32,9 +31,8 @@ export class VideoRedundanciesListComponent extends RestTable implements OnInit private notifier: Notifier, private confirmService: ConfirmService, private redundancyService: RedundancyService, - private serverService: ServerService, - private i18n: I18n - ) { + private serverService: ServerService + ) { super() this.bytesPipe = new BytesPipe() @@ -100,7 +98,7 @@ export class VideoRedundanciesListComponent extends RestTable implements OnInit this.redundanciesGraphsData.push({ stats, graphData: { - labels: [ this.i18n('Used'), this.i18n('Available') ], + labels: [ $localize`Used`, $localize`Available` ], datasets: [ { data: [ stats.totalUsed, totalSize ], @@ -139,14 +137,14 @@ export class VideoRedundanciesListComponent extends RestTable implements OnInit } async removeRedundancy (redundancy: VideoRedundancy) { - const message = this.i18n('Do you really want to remove this video redundancy?') - const res = await this.confirmService.confirm(message, this.i18n('Remove redundancy')) + const message = $localize`Do you really want to remove this video redundancy?` + const res = await this.confirmService.confirm(message, $localize`Remove redundancy`) if (res === false) return this.redundancyService.removeVideoRedundancies(redundancy) .subscribe( () => { - this.notifier.success(this.i18n('Video redundancies removed!')) + this.notifier.success($localize`Video redundancies removed!`) this.loadData() }, -- cgit v1.2.3