diff options
author | Chocobozzz <me@florianbigard.com> | 2020-08-12 10:40:04 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-08-14 10:28:30 +0200 |
commit | 66357162f8e1227495f09bd4f68446aad7071c6d (patch) | |
tree | 7d4429506deb512b2fe1d0267f38a28cda20af55 /client/src/app/+my-account/my-account-videos | |
parent | 8c360747995e17eb5520e22fc3d7bd4c3d26eeee (diff) | |
download | PeerTube-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/+my-account/my-account-videos')
2 files changed, 10 insertions, 15 deletions
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' | |||
7 | import { immutableAssign } from '@app/helpers' | 7 | import { immutableAssign } from '@app/helpers' |
8 | import { Video, VideoService } from '@app/shared/shared-main' | 8 | import { Video, VideoService } from '@app/shared/shared-main' |
9 | import { MiniatureDisplayOptions, OwnerDisplayType, SelectionType, VideosSelectionComponent } from '@app/shared/shared-video-miniature' | 9 | import { MiniatureDisplayOptions, OwnerDisplayType, SelectionType, VideosSelectionComponent } from '@app/shared/shared-video-miniature' |
10 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
11 | import { VideoSortField } from '@shared/models' | 10 | import { VideoSortField } from '@shared/models' |
12 | import { VideoChangeOwnershipComponent } from './video-change-ownership/video-change-ownership.component' | 11 | import { VideoChangeOwnershipComponent } from './video-change-ownership/video-change-ownership.component' |
13 | 12 | ||
@@ -50,11 +49,10 @@ export class MyAccountVideosComponent implements OnInit, DisableForReuseHook { | |||
50 | protected authService: AuthService, | 49 | protected authService: AuthService, |
51 | protected notifier: Notifier, | 50 | protected notifier: Notifier, |
52 | protected screenService: ScreenService, | 51 | protected screenService: ScreenService, |
53 | private i18n: I18n, | ||
54 | private confirmService: ConfirmService, | 52 | private confirmService: ConfirmService, |
55 | private videoService: VideoService | 53 | private videoService: VideoService |
56 | ) { | 54 | ) { |
57 | this.titlePage = this.i18n('My videos') | 55 | this.titlePage = $localize`My videos` |
58 | } | 56 | } |
59 | 57 | ||
60 | ngOnInit () { | 58 | ngOnInit () { |
@@ -97,8 +95,8 @@ export class MyAccountVideosComponent implements OnInit, DisableForReuseHook { | |||
97 | .map(k => parseInt(k, 10)) | 95 | .map(k => parseInt(k, 10)) |
98 | 96 | ||
99 | const res = await this.confirmService.confirm( | 97 | const res = await this.confirmService.confirm( |
100 | this.i18n('Do you really want to delete {{deleteLength}} videos?', { deleteLength: toDeleteVideosIds.length }), | 98 | $localize`Do you really want to delete ${toDeleteVideosIds.length} videos?`, |
101 | this.i18n('Delete') | 99 | $localize`Delete` |
102 | ) | 100 | ) |
103 | if (res === false) return | 101 | if (res === false) return |
104 | 102 | ||
@@ -114,8 +112,7 @@ export class MyAccountVideosComponent implements OnInit, DisableForReuseHook { | |||
114 | .pipe(toArray()) | 112 | .pipe(toArray()) |
115 | .subscribe( | 113 | .subscribe( |
116 | () => { | 114 | () => { |
117 | this.notifier.success(this.i18n('{{deleteLength}} videos deleted.', { deleteLength: toDeleteVideosIds.length })) | 115 | this.notifier.success($localize`${toDeleteVideosIds.length} videos deleted.`) |
118 | |||
119 | this.selection = {} | 116 | this.selection = {} |
120 | }, | 117 | }, |
121 | 118 | ||
@@ -125,15 +122,15 @@ export class MyAccountVideosComponent implements OnInit, DisableForReuseHook { | |||
125 | 122 | ||
126 | async deleteVideo (video: Video) { | 123 | async deleteVideo (video: Video) { |
127 | const res = await this.confirmService.confirm( | 124 | const res = await this.confirmService.confirm( |
128 | this.i18n('Do you really want to delete {{videoName}}?', { videoName: video.name }), | 125 | $localize`Do you really want to delete ${video.name}?`, |
129 | this.i18n('Delete') | 126 | $localize`Delete` |
130 | ) | 127 | ) |
131 | if (res === false) return | 128 | if (res === false) return |
132 | 129 | ||
133 | this.videoService.removeVideo(video.id) | 130 | this.videoService.removeVideo(video.id) |
134 | .subscribe( | 131 | .subscribe( |
135 | () => { | 132 | () => { |
136 | this.notifier.success(this.i18n('Video {{videoName}} deleted.', { videoName: video.name })) | 133 | this.notifier.success($localize`Video ${video.name} deleted.`) |
137 | this.removeVideoFromArray(video.id) | 134 | this.removeVideoFromArray(video.id) |
138 | }, | 135 | }, |
139 | 136 | ||
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' | |||
3 | import { FormReactive, FormValidatorService, VideoChangeOwnershipValidatorsService } from '@app/shared/shared-forms' | 3 | import { FormReactive, FormValidatorService, VideoChangeOwnershipValidatorsService } from '@app/shared/shared-forms' |
4 | import { Video, VideoOwnershipService } from '@app/shared/shared-main' | 4 | import { Video, VideoOwnershipService } from '@app/shared/shared-main' |
5 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' | 5 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' |
6 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
7 | 6 | ||
8 | @Component({ | 7 | @Component({ |
9 | selector: 'my-video-change-ownership', | 8 | selector: 'my-video-change-ownership', |
@@ -25,9 +24,8 @@ export class VideoChangeOwnershipComponent extends FormReactive implements OnIni | |||
25 | private videoOwnershipService: VideoOwnershipService, | 24 | private videoOwnershipService: VideoOwnershipService, |
26 | private notifier: Notifier, | 25 | private notifier: Notifier, |
27 | private userService: UserService, | 26 | private userService: UserService, |
28 | private modalService: NgbModal, | 27 | private modalService: NgbModal |
29 | private i18n: I18n | 28 | ) { |
30 | ) { | ||
31 | super() | 29 | super() |
32 | } | 30 | } |
33 | 31 | ||
@@ -63,7 +61,7 @@ export class VideoChangeOwnershipComponent extends FormReactive implements OnIni | |||
63 | this.videoOwnershipService | 61 | this.videoOwnershipService |
64 | .changeOwnership(this.video.id, username) | 62 | .changeOwnership(this.video.id, username) |
65 | .subscribe( | 63 | .subscribe( |
66 | () => this.notifier.success(this.i18n('Ownership change request sent.')), | 64 | () => this.notifier.success($localize`Ownership change request sent.`), |
67 | 65 | ||
68 | err => this.notifier.error(err.message) | 66 | err => this.notifier.error(err.message) |
69 | ) | 67 | ) |