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/+videos/+video-watch/video-duration-formatter.pipe.ts | |
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/+videos/+video-watch/video-duration-formatter.pipe.ts')
-rw-r--r-- | client/src/app/+videos/+video-watch/video-duration-formatter.pipe.ts | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/client/src/app/+videos/+video-watch/video-duration-formatter.pipe.ts b/client/src/app/+videos/+video-watch/video-duration-formatter.pipe.ts index 4b6767415..19b34f984 100644 --- a/client/src/app/+videos/+video-watch/video-duration-formatter.pipe.ts +++ b/client/src/app/+videos/+video-watch/video-duration-formatter.pipe.ts | |||
@@ -1,28 +1,23 @@ | |||
1 | import { Pipe, PipeTransform } from '@angular/core' | 1 | import { Pipe, PipeTransform } from '@angular/core' |
2 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
3 | 2 | ||
4 | @Pipe({ | 3 | @Pipe({ |
5 | name: 'myVideoDurationFormatter' | 4 | name: 'myVideoDurationFormatter' |
6 | }) | 5 | }) |
7 | export class VideoDurationPipe implements PipeTransform { | 6 | export class VideoDurationPipe implements PipeTransform { |
8 | 7 | ||
9 | constructor (private i18n: I18n) { | ||
10 | |||
11 | } | ||
12 | |||
13 | transform (value: number): string { | 8 | transform (value: number): string { |
14 | const hours = Math.floor(value / 3600) | 9 | const hours = Math.floor(value / 3600) |
15 | const minutes = Math.floor((value % 3600) / 60) | 10 | const minutes = Math.floor((value % 3600) / 60) |
16 | const seconds = value % 60 | 11 | const seconds = value % 60 |
17 | 12 | ||
18 | if (hours > 0) { | 13 | if (hours > 0) { |
19 | return this.i18n('{{hours}} h {{minutes}} min {{seconds}} sec', { hours, minutes, seconds }) | 14 | return $localize`${hours} h ${minutes} min ${seconds} sec` |
20 | } | 15 | } |
21 | 16 | ||
22 | if (minutes > 0) { | 17 | if (minutes > 0) { |
23 | return this.i18n('{{minutes}} min {{seconds}} sec', { minutes, seconds }) | 18 | return $localize`${minutes} min ${seconds} sec` |
24 | } | 19 | } |
25 | 20 | ||
26 | return this.i18n('{{seconds}} sec', { seconds }) | 21 | return $localize`${seconds} sec` |
27 | } | 22 | } |
28 | } | 23 | } |