aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-video-miniature/video-download.component.ts
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/shared/shared-video-miniature/video-download.component.ts
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/shared/shared-video-miniature/video-download.component.ts')
-rw-r--r--client/src/app/shared/shared-video-miniature/video-download.component.ts36
1 files changed, 17 insertions, 19 deletions
diff --git a/client/src/app/shared/shared-video-miniature/video-download.component.ts b/client/src/app/shared/shared-video-miniature/video-download.component.ts
index e3d6a1969..99838f712 100644
--- a/client/src/app/shared/shared-video-miniature/video-download.component.ts
+++ b/client/src/app/shared/shared-video-miniature/video-download.component.ts
@@ -2,7 +2,6 @@ import { mapValues, pick } from 'lodash-es'
2import { Component, ElementRef, ViewChild } from '@angular/core' 2import { Component, ElementRef, ViewChild } from '@angular/core'
3import { AuthService, Notifier } from '@app/core' 3import { AuthService, Notifier } from '@app/core'
4import { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap' 4import { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap'
5import { I18n } from '@ngx-translate/i18n-polyfill'
6import { VideoCaption, VideoFile, VideoPrivacy } from '@shared/models' 5import { VideoCaption, VideoFile, VideoPrivacy } from '@shared/models'
7import { BytesPipe, NumberFormatterPipe, VideoDetails, VideoService } from '../shared-main' 6import { BytesPipe, NumberFormatterPipe, VideoDetails, VideoService } from '../shared-main'
8 7
@@ -38,8 +37,7 @@ export class VideoDownloadComponent {
38 private notifier: Notifier, 37 private notifier: Notifier,
39 private modalService: NgbModal, 38 private modalService: NgbModal,
40 private videoService: VideoService, 39 private videoService: VideoService,
41 private auth: AuthService, 40 private auth: AuthService
42 private i18n: I18n
43 ) { 41 ) {
44 this.bytesPipe = new BytesPipe() 42 this.bytesPipe = new BytesPipe()
45 this.numbersPipe = new NumberFormatterPipe() 43 this.numbersPipe = new NumberFormatterPipe()
@@ -47,8 +45,8 @@ export class VideoDownloadComponent {
47 45
48 get typeText () { 46 get typeText () {
49 return this.type === 'video' 47 return this.type === 'video'
50 ? this.i18n('video') 48 ? $localize`video`
51 : this.i18n('subtitles') 49 : $localize`subtitles`
52 } 50 }
53 51
54 getVideoFiles () { 52 getVideoFiles () {
@@ -135,7 +133,7 @@ export class VideoDownloadComponent {
135 } 133 }
136 134
137 activateCopiedMessage () { 135 activateCopiedMessage () {
138 this.notifier.success(this.i18n('Copied')) 136 this.notifier.success($localize`Copied`)
139 } 137 }
140 138
141 switchToType (type: DownloadType) { 139 switchToType (type: DownloadType) {
@@ -144,11 +142,11 @@ export class VideoDownloadComponent {
144 142
145 getMetadataFormat (format: any) { 143 getMetadataFormat (format: any) {
146 const keyToTranslateFunction = { 144 const keyToTranslateFunction = {
147 'encoder': (value: string) => ({ label: this.i18n('Encoder'), value }), 145 'encoder': (value: string) => ({ label: $localize`Encoder`, value }),
148 'format_long_name': (value: string) => ({ label: this.i18n('Format name'), value }), 146 'format_long_name': (value: string) => ({ label: $localize`Format name`, value }),
149 'size': (value: number) => ({ label: this.i18n('Size'), value: this.bytesPipe.transform(value, 2) }), 147 'size': (value: number) => ({ label: $localize`Size`, value: this.bytesPipe.transform(value, 2) }),
150 'bit_rate': (value: number) => ({ 148 'bit_rate': (value: number) => ({
151 label: this.i18n('Bitrate'), 149 label: $localize`Bitrate`,
152 value: `${this.numbersPipe.transform(value)}bps` 150 value: `${this.numbersPipe.transform(value)}bps`
153 }) 151 })
154 } 152 }
@@ -168,25 +166,25 @@ export class VideoDownloadComponent {
168 if (!stream) return undefined 166 if (!stream) return undefined
169 167
170 let keyToTranslateFunction = { 168 let keyToTranslateFunction = {
171 'codec_long_name': (value: string) => ({ label: this.i18n('Codec'), value }), 169 'codec_long_name': (value: string) => ({ label: $localize`Codec`, value }),
172 'profile': (value: string) => ({ label: this.i18n('Profile'), value }), 170 'profile': (value: string) => ({ label: $localize`Profile`, value }),
173 'bit_rate': (value: number) => ({ 171 'bit_rate': (value: number) => ({
174 label: this.i18n('Bitrate'), 172 label: $localize`Bitrate`,
175 value: `${this.numbersPipe.transform(value)}bps` 173 value: `${this.numbersPipe.transform(value)}bps`
176 }) 174 })
177 } 175 }
178 176
179 if (type === 'video') { 177 if (type === 'video') {
180 keyToTranslateFunction = Object.assign(keyToTranslateFunction, { 178 keyToTranslateFunction = Object.assign(keyToTranslateFunction, {
181 'width': (value: number) => ({ label: this.i18n('Resolution'), value: `${value}x${stream.height}` }), 179 'width': (value: number) => ({ label: $localize`Resolution`, value: `${value}x${stream.height}` }),
182 'display_aspect_ratio': (value: string) => ({ label: this.i18n('Aspect ratio'), value }), 180 'display_aspect_ratio': (value: string) => ({ label: $localize`Aspect ratio`, value }),
183 'avg_frame_rate': (value: string) => ({ label: this.i18n('Average frame rate'), value }), 181 'avg_frame_rate': (value: string) => ({ label: $localize`Average frame rate`, value }),
184 'pix_fmt': (value: string) => ({ label: this.i18n('Pixel format'), value }) 182 'pix_fmt': (value: string) => ({ label: $localize`Pixel format`, value })
185 }) 183 })
186 } else { 184 } else {
187 keyToTranslateFunction = Object.assign(keyToTranslateFunction, { 185 keyToTranslateFunction = Object.assign(keyToTranslateFunction, {
188 'sample_rate': (value: number) => ({ label: this.i18n('Sample rate'), value }), 186 'sample_rate': (value: number) => ({ label: $localize`Sample rate`, value }),
189 'channel_layout': (value: number) => ({ label: this.i18n('Channel Layout'), value }) 187 'channel_layout': (value: number) => ({ label: $localize`Channel Layout`, value })
190 }) 188 })
191 } 189 }
192 190