aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+accounts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-08-12 10:40:04 +0200
committerChocobozzz <me@florianbigard.com>2020-08-14 10:28:30 +0200
commit66357162f8e1227495f09bd4f68446aad7071c6d (patch)
tree7d4429506deb512b2fe1d0267f38a28cda20af55 /client/src/app/+accounts
parent8c360747995e17eb5520e22fc3d7bd4c3d26eeee (diff)
downloadPeerTube-66357162f8e1227495f09bd4f68446aad7071c6d.tar.gz
PeerTube-66357162f8e1227495f09bd4f68446aad7071c6d.tar.zst
PeerTube-66357162f8e1227495f09bd4f68446aad7071c6d.zip
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
Diffstat (limited to 'client/src/app/+accounts')
-rw-r--r--client/src/app/+accounts/account-about/account-about.component.ts4
-rw-r--r--client/src/app/+accounts/account-videos/account-videos.component.ts4
-rw-r--r--client/src/app/+accounts/accounts.component.ts24
3 files changed, 13 insertions, 19 deletions
diff --git a/client/src/app/+accounts/account-about/account-about.component.ts b/client/src/app/+accounts/account-about/account-about.component.ts
index 8c01e4007..6cf846d72 100644
--- a/client/src/app/+accounts/account-about/account-about.component.ts
+++ b/client/src/app/+accounts/account-about/account-about.component.ts
@@ -2,7 +2,6 @@ import { Subscription } from 'rxjs'
2import { Component, OnDestroy, OnInit } from '@angular/core' 2import { Component, OnDestroy, OnInit } from '@angular/core'
3import { MarkdownService } from '@app/core' 3import { MarkdownService } from '@app/core'
4import { Account, AccountService } from '@app/shared/shared-main' 4import { Account, AccountService } from '@app/shared/shared-main'
5import { I18n } from '@ngx-translate/i18n-polyfill'
6 5
7@Component({ 6@Component({
8 selector: 'my-account-about', 7 selector: 'my-account-about',
@@ -16,7 +15,6 @@ export class AccountAboutComponent implements OnInit, OnDestroy {
16 private accountSub: Subscription 15 private accountSub: Subscription
17 16
18 constructor ( 17 constructor (
19 private i18n: I18n,
20 private accountService: AccountService, 18 private accountService: AccountService,
21 private markdownService: MarkdownService 19 private markdownService: MarkdownService
22 ) { } 20 ) { }
@@ -37,6 +35,6 @@ export class AccountAboutComponent implements OnInit, OnDestroy {
37 getAccountDescription () { 35 getAccountDescription () {
38 if (this.descriptionHTML) return this.descriptionHTML 36 if (this.descriptionHTML) return this.descriptionHTML
39 37
40 return this.i18n('No description') 38 return $localize`No description`
41 } 39 }
42} 40}
diff --git a/client/src/app/+accounts/account-videos/account-videos.component.ts b/client/src/app/+accounts/account-videos/account-videos.component.ts
index 5a9241f8e..3134a8ee2 100644
--- a/client/src/app/+accounts/account-videos/account-videos.component.ts
+++ b/client/src/app/+accounts/account-videos/account-videos.component.ts
@@ -6,7 +6,6 @@ import { AuthService, ConfirmService, LocalStorageService, Notifier, ScreenServi
6import { immutableAssign } from '@app/helpers' 6import { immutableAssign } from '@app/helpers'
7import { Account, AccountService, VideoService } from '@app/shared/shared-main' 7import { Account, AccountService, VideoService } from '@app/shared/shared-main'
8import { AbstractVideoList } from '@app/shared/shared-video-miniature' 8import { AbstractVideoList } from '@app/shared/shared-video-miniature'
9import { I18n } from '@ngx-translate/i18n-polyfill'
10 9
11@Component({ 10@Component({
12 selector: 'my-account-videos', 11 selector: 'my-account-videos',
@@ -23,7 +22,6 @@ export class AccountVideosComponent extends AbstractVideoList implements OnInit,
23 private accountSub: Subscription 22 private accountSub: Subscription
24 23
25 constructor ( 24 constructor (
26 protected i18n: I18n,
27 protected router: Router, 25 protected router: Router,
28 protected serverService: ServerService, 26 protected serverService: ServerService,
29 protected route: ActivatedRoute, 27 protected route: ActivatedRoute,
@@ -66,7 +64,7 @@ export class AccountVideosComponent extends AbstractVideoList implements OnInit,
66 .getAccountVideos(this.account, newPagination, this.sort) 64 .getAccountVideos(this.account, newPagination, this.sort)
67 .pipe( 65 .pipe(
68 tap(({ total }) => { 66 tap(({ total }) => {
69 this.titlePage = this.i18n('Published {{total}} videos', { total }) 67 this.titlePage = $localize`Published ${total} videos`
70 }) 68 })
71 ) 69 )
72 } 70 }
diff --git a/client/src/app/+accounts/accounts.component.ts b/client/src/app/+accounts/accounts.component.ts
index 9288fcb42..bbce62c35 100644
--- a/client/src/app/+accounts/accounts.component.ts
+++ b/client/src/app/+accounts/accounts.component.ts
@@ -5,7 +5,6 @@ import { ActivatedRoute } from '@angular/router'
5import { AuthService, Notifier, RedirectService, RestExtractor, ScreenService, UserService } from '@app/core' 5import { AuthService, Notifier, RedirectService, RestExtractor, ScreenService, UserService } from '@app/core'
6import { Account, AccountService, DropdownAction, ListOverflowItem, VideoChannel, VideoChannelService } from '@app/shared/shared-main' 6import { Account, AccountService, DropdownAction, ListOverflowItem, VideoChannel, VideoChannelService } from '@app/shared/shared-main'
7import { AccountReportComponent } from '@app/shared/shared-moderation' 7import { AccountReportComponent } from '@app/shared/shared-moderation'
8import { I18n } from '@ngx-translate/i18n-polyfill'
9import { User, UserRight } from '@shared/models' 8import { User, UserRight } from '@shared/models'
10 9
11@Component({ 10@Component({
@@ -36,8 +35,7 @@ export class AccountsComponent implements OnInit, OnDestroy {
36 private restExtractor: RestExtractor, 35 private restExtractor: RestExtractor,
37 private redirectService: RedirectService, 36 private redirectService: RedirectService,
38 private authService: AuthService, 37 private authService: AuthService,
39 private screenService: ScreenService, 38 private screenService: ScreenService
40 private i18n: I18n
41 ) { 39 ) {
42 } 40 }
43 41
@@ -58,9 +56,9 @@ export class AccountsComponent implements OnInit, OnDestroy {
58 ) 56 )
59 57
60 this.links = [ 58 this.links = [
61 { label: this.i18n('VIDEO CHANNELS'), routerLink: 'video-channels' }, 59 { label: $localize`VIDEO CHANNELS`, routerLink: 'video-channels' },
62 { label: this.i18n('VIDEOS'), routerLink: 'videos' }, 60 { label: $localize`VIDEOS`, routerLink: 'videos' },
63 { label: this.i18n('ABOUT'), routerLink: 'about' } 61 { label: $localize`ABOUT`, routerLink: 'about' }
64 ] 62 ]
65 } 63 }
66 64
@@ -88,11 +86,13 @@ export class AccountsComponent implements OnInit, OnDestroy {
88 } 86 }
89 87
90 activateCopiedMessage () { 88 activateCopiedMessage () {
91 this.notifier.success(this.i18n('Username copied')) 89 this.notifier.success($localize`Username copied`)
92 } 90 }
93 91
94 subscribersDisplayFor (count: number) { 92 subscribersDisplayFor (count: number) {
95 return this.i18n('{count, plural, =1 {1 subscriber} other {{{count}} subscribers}}', { count }) 93 if (count === 1) return $localize`1 subscriber`
94
95 return $localize`${count} subscribers`
96 } 96 }
97 97
98 private onAccount (account: Account) { 98 private onAccount (account: Account) {
@@ -105,16 +105,14 @@ export class AccountsComponent implements OnInit, OnDestroy {
105 () => { 105 () => {
106 this.isAccountManageable = this.account.userId && this.account.userId === this.authService.getUser().id 106 this.isAccountManageable = this.account.userId && this.account.userId === this.authService.getUser().id
107 107
108 this.accountFollowerTitle = this.i18n( 108 const followers = this.subscribersDisplayFor(account.followersCount)
109 '{{followers}} direct account followers', 109 this.accountFollowerTitle = $localize`${followers} direct account followers`
110 { followers: this.subscribersDisplayFor(account.followersCount) }
111 )
112 110
113 // It's not our account, we can report it 111 // It's not our account, we can report it
114 if (!this.isAccountManageable) { 112 if (!this.isAccountManageable) {
115 this.prependModerationActions = [ 113 this.prependModerationActions = [
116 { 114 {
117 label: this.i18n('Report account'), 115 label: $localize`Report account`,
118 handler: () => this.showReportModal() 116 handler: () => this.showReportModal()
119 } 117 }
120 ] 118 ]