diff options
author | Chocobozzz <me@florianbigard.com> | 2018-06-05 16:09:32 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-06-05 16:09:32 +0200 |
commit | 7a9fd8b54dd278cbb341daf96baca769bfe92ce9 (patch) | |
tree | 573caf90022feecca59f9e41b52eda82ece7519d /client/src/app | |
parent | e309822b93d9b69f30cbe830ef3d09dfdb2c13b2 (diff) | |
download | PeerTube-7a9fd8b54dd278cbb341daf96baca769bfe92ce9.tar.gz PeerTube-7a9fd8b54dd278cbb341daf96baca769bfe92ce9.tar.zst PeerTube-7a9fd8b54dd278cbb341daf96baca769bfe92ce9.zip |
Handle singular/plurial in signup
Diffstat (limited to 'client/src/app')
-rw-r--r-- | client/src/app/signup/signup.component.scss | 4 | ||||
-rw-r--r-- | client/src/app/signup/signup.component.ts | 31 |
2 files changed, 16 insertions, 19 deletions
diff --git a/client/src/app/signup/signup.component.scss b/client/src/app/signup/signup.component.scss index 6efb95ea6..8ea4ec997 100644 --- a/client/src/app/signup/signup.component.scss +++ b/client/src/app/signup/signup.component.scss | |||
@@ -8,10 +8,6 @@ | |||
8 | .initial-user-quota-label { | 8 | .initial-user-quota-label { |
9 | font-weight: $font-semibold; | 9 | font-weight: $font-semibold; |
10 | } | 10 | } |
11 | |||
12 | my-help { | ||
13 | margin-left: 5px; | ||
14 | } | ||
15 | } | 11 | } |
16 | 12 | ||
17 | 13 | ||
diff --git a/client/src/app/signup/signup.component.ts b/client/src/app/signup/signup.component.ts index a40f42cb1..55ebb573e 100644 --- a/client/src/app/signup/signup.component.ts +++ b/client/src/app/signup/signup.component.ts | |||
@@ -17,18 +17,6 @@ export class SignupComponent extends FormReactive implements OnInit { | |||
17 | error: string = null | 17 | error: string = null |
18 | quotaHelpIndication = '' | 18 | quotaHelpIndication = '' |
19 | 19 | ||
20 | private static getApproximateTime (seconds: number) { | ||
21 | const hours = Math.floor(seconds / 3600) | ||
22 | let pluralSuffix = '' | ||
23 | if (hours > 1) pluralSuffix = 's' | ||
24 | if (hours > 0) return `~ ${hours} hour${pluralSuffix}` | ||
25 | |||
26 | const minutes = Math.floor(seconds % 3600 / 60) | ||
27 | if (minutes > 1) pluralSuffix = 's' | ||
28 | |||
29 | return `~ ${minutes} minute${pluralSuffix}` | ||
30 | } | ||
31 | |||
32 | constructor ( | 20 | constructor ( |
33 | protected formValidatorService: FormValidatorService, | 21 | protected formValidatorService: FormValidatorService, |
34 | private userValidatorsService: UserValidatorsService, | 22 | private userValidatorsService: UserValidatorsService, |
@@ -75,6 +63,19 @@ export class SignupComponent extends FormReactive implements OnInit { | |||
75 | ) | 63 | ) |
76 | } | 64 | } |
77 | 65 | ||
66 | private getApproximateTime (seconds: number) { | ||
67 | const hours = Math.floor(seconds / 3600) | ||
68 | let pluralSuffix = '' | ||
69 | if (hours > 1) pluralSuffix = 's' | ||
70 | if (hours > 0) return `~ ${hours} hour${pluralSuffix}` | ||
71 | |||
72 | const minutes = Math.floor(seconds % 3600 / 60) | ||
73 | if (minutes > 1) pluralSuffix = 's' | ||
74 | |||
75 | return this.i18n('~ {{minutes}} {minutes, plural, =1 {minute} other {minutes}}', { minutes }) | ||
76 | } | ||
77 | |||
78 | |||
78 | private buildQuotaHelpIndication () { | 79 | private buildQuotaHelpIndication () { |
79 | if (this.initialUserVideoQuota === -1) return | 80 | if (this.initialUserVideoQuota === -1) return |
80 | 81 | ||
@@ -88,9 +89,9 @@ export class SignupComponent extends FormReactive implements OnInit { | |||
88 | const normalSeconds = initialUserVideoQuotaBit / (1.5 * 1000 * 1000) | 89 | const normalSeconds = initialUserVideoQuotaBit / (1.5 * 1000 * 1000) |
89 | 90 | ||
90 | const lines = [ | 91 | const lines = [ |
91 | this.i18n('{{seconds}} of full HD videos', { seconds: SignupComponent.getApproximateTime(fullHdSeconds) }), | 92 | this.i18n('{{seconds}} of full HD videos', { seconds: this.getApproximateTime(fullHdSeconds) }), |
92 | this.i18n('{{seconds}} of HD videos', { seconds: SignupComponent.getApproximateTime(hdSeconds) }), | 93 | this.i18n('{{seconds}} of HD videos', { seconds: this.getApproximateTime(hdSeconds) }), |
93 | this.i18n('{{seconds}} of average quality videos', { seconds: SignupComponent.getApproximateTime(normalSeconds) }) | 94 | this.i18n('{{seconds}} of average quality videos', { seconds: this.getApproximateTime(normalSeconds) }) |
94 | ] | 95 | ] |
95 | 96 | ||
96 | this.quotaHelpIndication = lines.join('<br />') | 97 | this.quotaHelpIndication = lines.join('<br />') |