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/core/rest/rest-extractor.service.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/core/rest/rest-extractor.service.ts')
-rw-r--r-- | client/src/app/core/rest/rest-extractor.service.ts | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/client/src/app/core/rest/rest-extractor.service.ts b/client/src/app/core/rest/rest-extractor.service.ts index 9de964f79..36702b371 100644 --- a/client/src/app/core/rest/rest-extractor.service.ts +++ b/client/src/app/core/rest/rest-extractor.service.ts | |||
@@ -2,16 +2,12 @@ import { throwError as observableThrowError } from 'rxjs' | |||
2 | import { Injectable } from '@angular/core' | 2 | import { Injectable } from '@angular/core' |
3 | import { Router } from '@angular/router' | 3 | import { Router } from '@angular/router' |
4 | import { dateToHuman } from '@app/helpers' | 4 | import { dateToHuman } from '@app/helpers' |
5 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
6 | import { ResultList } from '@shared/models' | 5 | import { ResultList } from '@shared/models' |
7 | 6 | ||
8 | @Injectable() | 7 | @Injectable() |
9 | export class RestExtractor { | 8 | export class RestExtractor { |
10 | 9 | ||
11 | constructor ( | 10 | constructor (private router: Router) { } |
12 | private router: Router, | ||
13 | private i18n: I18n | ||
14 | ) { } | ||
15 | 11 | ||
16 | extractDataBool () { | 12 | extractDataBool () { |
17 | return true | 13 | return true |
@@ -62,19 +58,18 @@ export class RestExtractor { | |||
62 | } else if (err.error && err.error.error) { | 58 | } else if (err.error && err.error.error) { |
63 | errorMessage = err.error.error | 59 | errorMessage = err.error.error |
64 | } else if (err.status === 413) { | 60 | } else if (err.status === 413) { |
65 | errorMessage = this.i18n( | 61 | errorMessage = $localize`Request is too large for the server. |
66 | 'Request is too large for the server. Please contact you administrator if you want to increase the limit size.' | 62 | Please contact you administrator if you want to increase the limit size.` |
67 | ) | ||
68 | } else if (err.status === 429) { | 63 | } else if (err.status === 429) { |
69 | const secondsLeft = err.headers.get('retry-after') | 64 | const secondsLeft = err.headers.get('retry-after') |
70 | if (secondsLeft) { | 65 | if (secondsLeft) { |
71 | const minutesLeft = Math.floor(parseInt(secondsLeft, 10) / 60) | 66 | const minutesLeft = Math.floor(parseInt(secondsLeft, 10) / 60) |
72 | errorMessage = this.i18n('Too many attempts, please try again after {{minutesLeft}} minutes.', { minutesLeft }) | 67 | errorMessage = $localize`Too many attempts, please try again after ${minutesLeft} minutes.` |
73 | } else { | 68 | } else { |
74 | errorMessage = this.i18n('Too many attempts, please try again later.') | 69 | errorMessage = $localize`Too many attempts, please try again later.` |
75 | } | 70 | } |
76 | } else if (err.status === 500) { | 71 | } else if (err.status === 500) { |
77 | errorMessage = this.i18n('Server error. Please retry later.') | 72 | errorMessage = $localize`Server error. Please retry later.` |
78 | } | 73 | } |
79 | 74 | ||
80 | errorMessage = errorMessage ? errorMessage : 'Unknown error.' | 75 | errorMessage = errorMessage ? errorMessage : 'Unknown error.' |