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 --- .../app/shared/shared-moderation/abuse.service.ts | 34 ++++--- .../account-blocklist.component.ts | 10 +- .../batch-domains-modal.component.ts | 6 +- .../report-modals/account-report.component.ts | 8 +- .../report-modals/comment-report.component.ts | 8 +- .../report-modals/video-report.component.ts | 8 +- .../server-blocklist.component.ts | 12 +-- .../shared-moderation/user-ban-modal.component.ts | 8 +- .../user-moderation-dropdown.component.ts | 103 ++++++++++----------- .../shared-moderation/video-block.component.ts | 6 +- 10 files changed, 90 insertions(+), 113 deletions(-) (limited to 'client/src/app/shared/shared-moderation') diff --git a/client/src/app/shared/shared-moderation/abuse.service.ts b/client/src/app/shared/shared-moderation/abuse.service.ts index 06b236d1e..bf98d4b36 100644 --- a/client/src/app/shared/shared-moderation/abuse.service.ts +++ b/client/src/app/shared/shared-moderation/abuse.service.ts @@ -5,7 +5,6 @@ import { catchError, map } from 'rxjs/operators' import { HttpClient, HttpParams } from '@angular/common/http' import { Injectable } from '@angular/core' import { RestExtractor, RestPagination, RestService } from '@app/core' -import { I18n } from '@ngx-translate/i18n-polyfill' import { AbuseCreate, AbuseFilter, @@ -25,7 +24,6 @@ export class AbuseService { private static BASE_MY_ABUSE_URL = environment.apiUrl + '/api/v1/users/me/abuses' constructor ( - private i18n: I18n, private authHttp: HttpClient, private restService: RestService, private restExtractor: RestExtractor @@ -138,33 +136,33 @@ export class AbuseService { let reasons: { id: AbusePredefinedReasonsString, label: string, description?: string, help?: string }[] = [ { id: 'violentOrRepulsive', - label: this.i18n('Violent or repulsive'), - help: this.i18n('Contains offensive, violent, or coarse language or iconography.') + label: $localize`Violent or repulsive`, + help: $localize`Contains offensive, violent, or coarse language or iconography.` }, { id: 'hatefulOrAbusive', - label: this.i18n('Hateful or abusive'), - help: this.i18n('Contains abusive, racist or sexist language or iconography.') + label: $localize`Hateful or abusive`, + help: $localize`Contains abusive, racist or sexist language or iconography.` }, { id: 'spamOrMisleading', - label: this.i18n('Spam, ad or false news'), - help: this.i18n('Contains marketing, spam, purposefully deceitful news, or otherwise misleading thumbnail/text/tags. Please provide reputable sources to report hoaxes.') + label: $localize`Spam, ad or false news`, + help: $localize`Contains marketing, spam, purposefully deceitful news, or otherwise misleading thumbnail/text/tags. Please provide reputable sources to report hoaxes.` }, { id: 'privacy', - label: this.i18n('Privacy breach or doxxing'), - help: this.i18n('Contains personal information that could be used to track, identify, contact or impersonate someone (e.g. name, address, phone number, email, or credit card details).') + label: $localize`Privacy breach or doxxing`, + help: $localize`Contains personal information that could be used to track, identify, contact or impersonate someone (e.g. name, address, phone number, email, or credit card details).` }, { id: 'rights', - label: this.i18n('Copyright'), - help: this.i18n('Infringes your copyright wrt. the regional laws with which the server must comply.') + label: $localize`Copyright`, + help: $localize`Infringes your copyright wrt. the regional laws with which the server must comply.` }, { id: 'serverRules', - label: this.i18n('Breaks server rules'), - description: this.i18n('Anything not included in the above that breaks the terms of service, code of conduct, or general rules in place on the server.') + label: $localize`Breaks server rules`, + description: $localize`Anything not included in the above that breaks the terms of service, code of conduct, or general rules in place on the server.` } ] @@ -172,13 +170,13 @@ export class AbuseService { reasons = reasons.concat([ { id: 'thumbnails', - label: this.i18n('Thumbnails'), - help: this.i18n('The above can only be seen in thumbnails.') + label: $localize`Thumbnails`, + help: $localize`The above can only be seen in thumbnails.` }, { id: 'captions', - label: this.i18n('Captions'), - help: this.i18n('The above can only be seen in captions (please describe which).') + label: $localize`Captions`, + help: $localize`The above can only be seen in captions (please describe which).` } ]) } diff --git a/client/src/app/shared/shared-moderation/account-blocklist.component.ts b/client/src/app/shared/shared-moderation/account-blocklist.component.ts index a5a3c27cd..68928a2c2 100644 --- a/client/src/app/shared/shared-moderation/account-blocklist.component.ts +++ b/client/src/app/shared/shared-moderation/account-blocklist.component.ts @@ -1,8 +1,7 @@ import { SortMeta } from 'primeng/api' -import { OnInit, Directive } from '@angular/core' +import { Directive, OnInit } from '@angular/core' import { Notifier, RestPagination, RestTable } from '@app/core' import { Actor } from '@app/shared/shared-main' -import { I18n } from '@ngx-translate/i18n-polyfill' import { AccountBlock } from './account-block.model' import { BlocklistComponentType, BlocklistService } from './blocklist.service' @@ -19,8 +18,7 @@ export class GenericAccountBlocklistComponent extends RestTable implements OnIni constructor ( private notifier: Notifier, - private blocklistService: BlocklistService, - private i18n: I18n + private blocklistService: BlocklistService ) { super() } @@ -46,8 +44,8 @@ export class GenericAccountBlocklistComponent extends RestTable implements OnIni () => { this.notifier.success( this.mode === BlocklistComponentType.Account - ? this.i18n('Account {{nameWithHost}} unmuted.', { nameWithHost: blockedAccount.nameWithHost }) - : this.i18n('Account {{nameWithHost}} unmuted by your instance.', { nameWithHost: blockedAccount.nameWithHost }) + ? $localize`Account ${blockedAccount.nameWithHost} unmuted.` + : $localize`Account ${blockedAccount.nameWithHost} unmuted by your instance.` ) this.loadData() diff --git a/client/src/app/shared/shared-moderation/batch-domains-modal.component.ts b/client/src/app/shared/shared-moderation/batch-domains-modal.component.ts index fdd4a79a9..7193ccb1b 100644 --- a/client/src/app/shared/shared-moderation/batch-domains-modal.component.ts +++ b/client/src/app/shared/shared-moderation/batch-domains-modal.component.ts @@ -2,7 +2,6 @@ import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angu import { BatchDomainsValidatorsService, FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' -import { I18n } from '@ngx-translate/i18n-polyfill' @Component({ selector: 'my-batch-domains-modal', @@ -20,14 +19,13 @@ export class BatchDomainsModalComponent extends FormReactive implements OnInit { constructor ( protected formValidatorService: FormValidatorService, private modalService: NgbModal, - private batchDomainsValidatorsService: BatchDomainsValidatorsService, - private i18n: I18n + private batchDomainsValidatorsService: BatchDomainsValidatorsService ) { super() } ngOnInit () { - if (!this.action) this.action = this.i18n('Process domains') + if (!this.action) this.action = $localize`Process domains` this.buildForm({ domains: this.batchDomainsValidatorsService.DOMAINS diff --git a/client/src/app/shared/shared-moderation/report-modals/account-report.component.ts b/client/src/app/shared/shared-moderation/report-modals/account-report.component.ts index 08dbe9538..8ab2fe940 100644 --- a/client/src/app/shared/shared-moderation/report-modals/account-report.component.ts +++ b/client/src/app/shared/shared-moderation/report-modals/account-report.component.ts @@ -5,7 +5,6 @@ import { AbuseValidatorsService, FormReactive, FormValidatorService } from '@app import { Account } from '@app/shared/shared-main' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' -import { I18n } from '@ngx-translate/i18n-polyfill' import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse' import { AbusePredefinedReasonsString } from '@shared/models' import { AbuseService } from '../abuse.service' @@ -31,8 +30,7 @@ export class AccountReportComponent extends FormReactive implements OnInit { private modalService: NgbModal, private abuseValidatorsService: AbuseValidatorsService, private abuseService: AbuseService, - private notifier: Notifier, - private i18n: I18n + private notifier: Notifier ) { super() } @@ -50,7 +48,7 @@ export class AccountReportComponent extends FormReactive implements OnInit { } ngOnInit () { - this.modalTitle = this.i18n('Report {{displayName}}', { displayName: this.account.displayName }) + this.modalTitle = $localize`Report ${this.account.displayName}` this.buildForm({ reason: this.abuseValidatorsService.ABUSE_REASON, @@ -81,7 +79,7 @@ export class AccountReportComponent extends FormReactive implements OnInit { } }).subscribe( () => { - this.notifier.success(this.i18n('Account reported.')) + this.notifier.success($localize`Account reported.`) this.hide() }, diff --git a/client/src/app/shared/shared-moderation/report-modals/comment-report.component.ts b/client/src/app/shared/shared-moderation/report-modals/comment-report.component.ts index 2769874d9..d75f4d717 100644 --- a/client/src/app/shared/shared-moderation/report-modals/comment-report.component.ts +++ b/client/src/app/shared/shared-moderation/report-modals/comment-report.component.ts @@ -5,7 +5,6 @@ import { AbuseValidatorsService, FormReactive, FormValidatorService } from '@app import { VideoComment } from '@app/shared/shared-video-comment' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' -import { I18n } from '@ngx-translate/i18n-polyfill' import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse' import { AbusePredefinedReasonsString } from '@shared/models' import { AbuseService } from '../abuse.service' @@ -31,8 +30,7 @@ export class CommentReportComponent extends FormReactive implements OnInit { private modalService: NgbModal, private abuseValidatorsService: AbuseValidatorsService, private abuseService: AbuseService, - private notifier: Notifier, - private i18n: I18n + private notifier: Notifier ) { super() } @@ -50,7 +48,7 @@ export class CommentReportComponent extends FormReactive implements OnInit { } ngOnInit () { - this.modalTitle = this.i18n('Report comment') + this.modalTitle = $localize`Report comment` this.buildForm({ reason: this.abuseValidatorsService.ABUSE_REASON, @@ -81,7 +79,7 @@ export class CommentReportComponent extends FormReactive implements OnInit { } }).subscribe( () => { - this.notifier.success(this.i18n('Comment reported.')) + this.notifier.success($localize`Comment reported.`) this.hide() }, diff --git a/client/src/app/shared/shared-moderation/report-modals/video-report.component.ts b/client/src/app/shared/shared-moderation/report-modals/video-report.component.ts index 794dd54bb..edff6d325 100644 --- a/client/src/app/shared/shared-moderation/report-modals/video-report.component.ts +++ b/client/src/app/shared/shared-moderation/report-modals/video-report.component.ts @@ -1,12 +1,11 @@ import { mapValues, pickBy } from 'lodash-es' -import { buildVideoOrPlaylistEmbed, buildVideoLink } from 'src/assets/player/utils' +import { buildVideoLink, buildVideoOrPlaylistEmbed } from 'src/assets/player/utils' import { Component, Input, OnInit, ViewChild } from '@angular/core' import { DomSanitizer, SafeHtml } from '@angular/platform-browser' import { Notifier } from '@app/core' import { AbuseValidatorsService, FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' -import { I18n } from '@ngx-translate/i18n-polyfill' import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse' import { AbusePredefinedReasonsString } from '@shared/models' import { Video } from '../../shared-main' @@ -34,8 +33,7 @@ export class VideoReportComponent extends FormReactive implements OnInit { private abuseValidatorsService: AbuseValidatorsService, private abuseService: AbuseService, private notifier: Notifier, - private sanitizer: DomSanitizer, - private i18n: I18n + private sanitizer: DomSanitizer ) { super() } @@ -109,7 +107,7 @@ export class VideoReportComponent extends FormReactive implements OnInit { } }).subscribe( () => { - this.notifier.success(this.i18n('Video reported.')) + this.notifier.success($localize`Video reported.`) this.hide() }, diff --git a/client/src/app/shared/shared-moderation/server-blocklist.component.ts b/client/src/app/shared/shared-moderation/server-blocklist.component.ts index 8f65cdb71..546fd53c3 100644 --- a/client/src/app/shared/shared-moderation/server-blocklist.component.ts +++ b/client/src/app/shared/shared-moderation/server-blocklist.component.ts @@ -2,7 +2,6 @@ import { SortMeta } from 'primeng/api' import { Directive, OnInit, ViewChild } from '@angular/core' import { Notifier, RestPagination, RestTable } from '@app/core' import { BatchDomainsModalComponent } from '@app/shared/shared-moderation/batch-domains-modal.component' -import { I18n } from '@ngx-translate/i18n-polyfill' import { ServerBlock } from '@shared/models' import { BlocklistComponentType, BlocklistService } from './blocklist.service' @@ -21,8 +20,7 @@ export class GenericServerBlocklistComponent extends RestTable implements OnInit constructor ( protected notifier: Notifier, - protected blocklistService: BlocklistService, - protected i18n: I18n + protected blocklistService: BlocklistService ) { super() } @@ -44,8 +42,8 @@ export class GenericServerBlocklistComponent extends RestTable implements OnInit () => { this.notifier.success( this.mode === BlocklistComponentType.Account - ? this.i18n('Instance {{host}} unmuted.', { host }) - : this.i18n('Instance {{host}} unmuted by your instance.', { host }) + ? $localize`Instance ${host} unmuted.` + : $localize`Instance ${host} unmuted by your instance.` ) this.loadData() @@ -67,8 +65,8 @@ export class GenericServerBlocklistComponent extends RestTable implements OnInit () => { this.notifier.success( this.mode === BlocklistComponentType.Account - ? this.i18n('Instance {{domain}} muted.', { domain }) - : this.i18n('Instance {{domain}} muted by your instance.', { domain }) + ? $localize`Instance ${domain} muted.` + : $localize`Instance ${domain} muted by your instance.` ) this.loadData() diff --git a/client/src/app/shared/shared-moderation/user-ban-modal.component.ts b/client/src/app/shared/shared-moderation/user-ban-modal.component.ts index 124e58669..f9a0381c5 100644 --- a/client/src/app/shared/shared-moderation/user-ban-modal.component.ts +++ b/client/src/app/shared/shared-moderation/user-ban-modal.component.ts @@ -3,7 +3,6 @@ import { Notifier, UserService } from '@app/core' import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' -import { I18n } from '@ngx-translate/i18n-polyfill' import { User } from '@shared/models' @Component({ @@ -23,8 +22,7 @@ export class UserBanModalComponent extends FormReactive implements OnInit { private modalService: NgbModal, private notifier: Notifier, private userService: UserService, - private userValidatorsService: UserValidatorsService, - private i18n: I18n + private userValidatorsService: UserValidatorsService ) { super() } @@ -52,8 +50,8 @@ export class UserBanModalComponent extends FormReactive implements OnInit { .subscribe( () => { const message = Array.isArray(this.usersToBan) - ? this.i18n('{{num}} users banned.', { num: this.usersToBan.length }) - : this.i18n('User {{username}} banned.', { username: this.usersToBan.username }) + ? $localize`${this.usersToBan.length} users banned.` + : $localize`User ${this.usersToBan.username} banned.` this.notifier.success(message) diff --git a/client/src/app/shared/shared-moderation/user-moderation-dropdown.component.ts b/client/src/app/shared/shared-moderation/user-moderation-dropdown.component.ts index 34fa7366c..44aefa853 100644 --- a/client/src/app/shared/shared-moderation/user-moderation-dropdown.component.ts +++ b/client/src/app/shared/shared-moderation/user-moderation-dropdown.component.ts @@ -1,7 +1,6 @@ import { Component, EventEmitter, Input, OnChanges, OnInit, Output, ViewChild } from '@angular/core' import { AuthService, ConfirmService, Notifier, ServerService, UserService } from '@app/core' import { Account, DropdownAction } from '@app/shared/shared-main' -import { I18n } from '@ngx-translate/i18n-polyfill' import { BulkRemoveCommentsOfBody, ServerConfig, User, UserRight } from '@shared/models' import { BlocklistService } from './blocklist.service' import { BulkService } from './bulk.service' @@ -37,8 +36,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { private serverService: ServerService, private userService: UserService, private blocklistService: BlocklistService, - private bulkService: BulkService, - private i18n: I18n + private bulkService: BulkService ) { } get requiresEmailVerification () { @@ -57,7 +55,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { openBanUserModal (user: User) { if (user.username === 'root') { - this.notifier.error(this.i18n('You cannot ban root.')) + this.notifier.error($localize`You cannot ban root.`) return } @@ -69,15 +67,13 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { } async unbanUser (user: User) { - const message = this.i18n('Do you really want to unban {{username}}?', { username: user.username }) - const res = await this.confirmService.confirm(message, this.i18n('Unban')) + const res = await this.confirmService.confirm($localize`Do you really want to unban ${user.username}?`, $localize`Unban`) if (res === false) return this.userService.unbanUsers(user) .subscribe( () => { - this.notifier.success(this.i18n('User {{username}} unbanned.', { username: user.username })) - + this.notifier.success($localize`User ${user.username} unbanned.`) this.userChanged.emit() }, @@ -87,17 +83,17 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { async removeUser (user: User) { if (user.username === 'root') { - this.notifier.error(this.i18n('You cannot delete root.')) + this.notifier.error($localize`You cannot delete root.`) return } - const message = this.i18n('If you remove this user, you will not be able to create another with the same username!') - const res = await this.confirmService.confirm(message, this.i18n('Delete')) + const message = $localize`If you remove this user, you will not be able to create another with the same username!` + const res = await this.confirmService.confirm(message, $localize`Delete`) if (res === false) return this.userService.removeUser(user).subscribe( () => { - this.notifier.success(this.i18n('User {{username}} deleted.', { username: user.username })) + this.notifier.success($localize`User ${user.username} deleted.`) this.userDeleted.emit() }, @@ -108,8 +104,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { setEmailAsVerified (user: User) { this.userService.updateUser(user.id, { emailVerified: true }).subscribe( () => { - this.notifier.success(this.i18n('User {{username}} email set as verified', { username: user.username })) - + this.notifier.success($localize`User ${user.username} email set as verified`) this.userChanged.emit() }, @@ -121,7 +116,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { this.blocklistService.blockAccountByUser(account) .subscribe( () => { - this.notifier.success(this.i18n('Account {{nameWithHost}} muted.', { nameWithHost: account.nameWithHost })) + this.notifier.success($localize`Account ${account.nameWithHost} muted.`) this.account.mutedByUser = true this.userChanged.emit() @@ -135,7 +130,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { this.blocklistService.unblockAccountByUser(account) .subscribe( () => { - this.notifier.success(this.i18n('Account {{nameWithHost}} unmuted.', { nameWithHost: account.nameWithHost })) + this.notifier.success($localize`Account ${account.nameWithHost} unmuted.`) this.account.mutedByUser = false this.userChanged.emit() @@ -149,7 +144,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { this.blocklistService.blockServerByUser(host) .subscribe( () => { - this.notifier.success(this.i18n('Instance {{host}} muted.', { host })) + this.notifier.success($localize`Instance ${host} muted.`) this.account.mutedServerByUser = true this.userChanged.emit() @@ -163,7 +158,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { this.blocklistService.unblockServerByUser(host) .subscribe( () => { - this.notifier.success(this.i18n('Instance {{host}} unmuted.', { host })) + this.notifier.success($localize`Instance ${host} unmuted.`) this.account.mutedServerByUser = false this.userChanged.emit() @@ -177,7 +172,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { this.blocklistService.blockAccountByInstance(account) .subscribe( () => { - this.notifier.success(this.i18n('Account {{nameWithHost}} muted by the instance.', { nameWithHost: account.nameWithHost })) + this.notifier.success($localize`Account ${account.nameWithHost} muted by the instance.`) this.account.mutedByInstance = true this.userChanged.emit() @@ -191,7 +186,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { this.blocklistService.unblockAccountByInstance(account) .subscribe( () => { - this.notifier.success(this.i18n('Account {{nameWithHost}} unmuted by the instance.', { nameWithHost: account.nameWithHost })) + this.notifier.success($localize`Account ${account.nameWithHost} unmuted by the instance.`) this.account.mutedByInstance = false this.userChanged.emit() @@ -205,7 +200,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { this.blocklistService.blockServerByInstance(host) .subscribe( () => { - this.notifier.success(this.i18n('Instance {{host}} muted by the instance.', { host })) + this.notifier.success($localize`Instance ${host} muted by the instance.`) this.account.mutedServerByInstance = true this.userChanged.emit() @@ -219,7 +214,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { this.blocklistService.unblockServerByInstance(host) .subscribe( () => { - this.notifier.success(this.i18n('Instance {{host}} unmuted by the instance.', { host })) + this.notifier.success($localize`Instance ${host} unmuted by the instance.`) this.account.mutedServerByInstance = false this.userChanged.emit() @@ -230,14 +225,14 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { } async bulkRemoveCommentsOf (body: BulkRemoveCommentsOfBody) { - const message = this.i18n('Are you sure you want to remove all the comments of this account?') - const res = await this.confirmService.confirm(message, this.i18n('Delete account comments')) + const message = $localize`Are you sure you want to remove all the comments of this account?` + const res = await this.confirmService.confirm(message, $localize`Delete account comments`) if (res === false) return this.bulkService.removeCommentsOf(body) .subscribe( () => { - this.notifier.success(this.i18n('Will remove comments of this account (may take several minutes).')) + this.notifier.success($localize`Will remove comments of this account (may take several minutes).`) }, err => this.notifier.error(err.message) @@ -265,29 +260,29 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { if (this.user && authUser.hasRight(UserRight.MANAGE_USERS) && authUser.canManage(this.user)) { this.userActions.push([ { - label: this.i18n('Edit user'), - description: this.i18n('Change quota, role, and more.'), + label: $localize`Edit user`, + description: $localize`Change quota, role, and more.`, linkBuilder: ({ user }) => this.getRouterUserEditLink(user) }, { - label: this.i18n('Delete user'), - description: this.i18n('Videos will be deleted, comments will be tombstoned.'), + label: $localize`Delete user`, + description: $localize`Videos will be deleted, comments will be tombstoned.`, handler: ({ user }) => this.removeUser(user) }, { - label: this.i18n('Ban'), - description: this.i18n('User won\'t be able to login anymore, but videos and comments will be kept as is.'), + label: $localize`Ban`, + description: $localize`User won't be able to login anymore, but videos and comments will be kept as is.`, handler: ({ user }) => this.openBanUserModal(user), isDisplayed: ({ user }) => !user.blocked }, { - label: this.i18n('Unban user'), - description: this.i18n('Allow the user to login and create videos/comments again'), + label: $localize`Unban user`, + description: $localize`Allow the user to login and create videos/comments again`, handler: ({ user }) => this.unbanUser(user), isDisplayed: ({ user }) => user.blocked }, { - label: this.i18n('Set Email as Verified'), + label: $localize`Set Email as Verified`, handler: ({ user }) => this.setEmailAsVerified(user), isDisplayed: ({ user }) => this.requiresEmailVerification && !user.blocked && user.emailVerified === false } @@ -299,32 +294,32 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { // User actions this.userActions.push([ { - label: this.i18n('Mute this account'), - description: this.i18n('Hide any content from that user for you.'), + label: $localize`Mute this account`, + description: $localize`Hide any content from that user for you.`, isDisplayed: ({ account }) => account.mutedByUser === false, handler: ({ account }) => this.blockAccountByUser(account) }, { - label: this.i18n('Unmute this account'), - description: this.i18n('Show back content from that user for you.'), + label: $localize`Unmute this account`, + description: $localize`Show back content from that user for you.`, isDisplayed: ({ account }) => account.mutedByUser === true, handler: ({ account }) => this.unblockAccountByUser(account) }, { - label: this.i18n('Mute the instance'), - description: this.i18n('Hide any content from that instance for you.'), + label: $localize`Mute the instance`, + description: $localize`Hide any content from that instance for you.`, isDisplayed: ({ account }) => !account.userId && account.mutedServerByInstance === false, handler: ({ account }) => this.blockServerByUser(account.host) }, { - label: this.i18n('Unmute the instance'), - description: this.i18n('Show back content from that instance for you.'), + label: $localize`Unmute the instance`, + description: $localize`Show back content from that instance for you.`, isDisplayed: ({ account }) => !account.userId && account.mutedServerByInstance === true, handler: ({ account }) => this.unblockServerByUser(account.host) }, { - label: this.i18n('Remove comments from your videos'), - description: this.i18n('Remove comments of this account from your videos.'), + label: $localize`Remove comments from your videos`, + description: $localize`Remove comments of this account from your videos.`, handler: ({ account }) => this.bulkRemoveCommentsOf({ accountName: account.nameWithHost, scope: 'my-videos' }) } ]) @@ -335,14 +330,14 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { if (authUser.hasRight(UserRight.MANAGE_ACCOUNTS_BLOCKLIST)) { instanceActions = instanceActions.concat([ { - label: this.i18n('Mute this account by your instance'), - description: this.i18n('Hide any content from that user for you, your instance and its users.'), + label: $localize`Mute this account by your instance`, + description: $localize`Hide any content from that user for you, your instance and its users.`, isDisplayed: ({ account }) => account.mutedByInstance === false, handler: ({ account }) => this.blockAccountByInstance(account) }, { - label: this.i18n('Unmute this account by your instance'), - description: this.i18n('Show back content from that user for you, your instance and its users.'), + label: $localize`Unmute this account by your instance`, + description: $localize`Show back content from that user for you, your instance and its users.`, isDisplayed: ({ account }) => account.mutedByInstance === true, handler: ({ account }) => this.unblockAccountByInstance(account) } @@ -353,14 +348,14 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { if (authUser.hasRight(UserRight.MANAGE_SERVERS_BLOCKLIST)) { instanceActions = instanceActions.concat([ { - label: this.i18n('Mute the instance by your instance'), - description: this.i18n('Hide any content from that instance for you, your instance and its users.'), + label: $localize`Mute the instance by your instance`, + description: $localize`Hide any content from that instance for you, your instance and its users.`, isDisplayed: ({ account }) => !account.userId && account.mutedServerByInstance === false, handler: ({ account }) => this.blockServerByInstance(account.host) }, { - label: this.i18n('Unmute the instance by your instance'), - description: this.i18n('Show back content from that instance for you, your instance and its users.'), + label: $localize`Unmute the instance by your instance`, + description: $localize`Show back content from that instance for you, your instance and its users.`, isDisplayed: ({ account }) => !account.userId && account.mutedServerByInstance === true, handler: ({ account }) => this.unblockServerByInstance(account.host) } @@ -370,8 +365,8 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { if (authUser.hasRight(UserRight.REMOVE_ANY_VIDEO_COMMENT)) { instanceActions = instanceActions.concat([ { - label: this.i18n('Remove comments from your instance'), - description: this.i18n('Remove comments of this account from your instance.'), + label: $localize`Remove comments from your instance`, + description: $localize`Remove comments of this account from your instance.`, handler: ({ account }) => this.bulkRemoveCommentsOf({ accountName: account.nameWithHost, scope: 'instance' }) } ]) diff --git a/client/src/app/shared/shared-moderation/video-block.component.ts b/client/src/app/shared/shared-moderation/video-block.component.ts index 054651e71..2bef9efdd 100644 --- a/client/src/app/shared/shared-moderation/video-block.component.ts +++ b/client/src/app/shared/shared-moderation/video-block.component.ts @@ -4,7 +4,6 @@ import { FormReactive, FormValidatorService, VideoBlockValidatorsService } from import { Video } from '@app/shared/shared-main' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' -import { I18n } from '@ngx-translate/i18n-polyfill' import { VideoBlockService } from './video-block.service' @Component({ @@ -28,8 +27,7 @@ export class VideoBlockComponent extends FormReactive implements OnInit { private modalService: NgbModal, private videoBlockValidatorsService: VideoBlockValidatorsService, private videoBlocklistService: VideoBlockService, - private notifier: Notifier, - private i18n: I18n + private notifier: Notifier ) { super() } @@ -59,7 +57,7 @@ export class VideoBlockComponent extends FormReactive implements OnInit { this.videoBlocklistService.blockVideo(this.video.id, reason, unfederate) .subscribe( () => { - this.notifier.success(this.i18n('Video blocked.')) + this.notifier.success($localize`Video blocked.`) this.hide() this.video.blacklisted = true -- cgit v1.2.3