From b1d40cff89f7cff565a98cdbcea9a624196a169a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 4 Jun 2018 16:21:17 +0200 Subject: Add i18n attributes --- client/src/app/shared/rest/rest-extractor.service.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'client/src/app/shared/rest') diff --git a/client/src/app/shared/rest/rest-extractor.service.ts b/client/src/app/shared/rest/rest-extractor.service.ts index 39e601e20..468ac3e32 100644 --- a/client/src/app/shared/rest/rest-extractor.service.ts +++ b/client/src/app/shared/rest/rest-extractor.service.ts @@ -3,11 +3,15 @@ import { Injectable } from '@angular/core' import { dateToHuman } from '@app/shared/misc/utils' import { ResultList } from '../../../../../shared' import { Router } from '@angular/router' +import { I18n } from '@ngx-translate/i18n-polyfill' @Injectable() export class RestExtractor { - constructor (private router: Router) { + constructor ( + private router: Router, + private i18n: I18n + ) { // empty } @@ -60,17 +64,19 @@ export class RestExtractor { } else if (err.error && err.error.error) { errorMessage = err.error.error } else if (err.status === 413) { - errorMessage = 'Request is too large for the server. Please contact you administrator if you want to increase the limit size.' + errorMessage = this.i18n( + 'Request is too large for the server. Please contact you administrator if you want to increase the limit size.' + ) } else if (err.status === 429) { const secondsLeft = err.headers.get('retry-after') if (secondsLeft) { const minutesLeft = Math.floor(parseInt(secondsLeft, 10) / 60) - errorMessage = 'Too many attempts, please try again after ' + minutesLeft + ' minutes.' + errorMessage = this.i18n('Too many attempts, please try again after {{ minutesLeft }} minutes.', { minutesLeft }) } else { - errorMessage = 'Too many attempts, please try again later.' + errorMessage = this.i18n('Too many attempts, please try again later.') } } else if (err.status === 500) { - errorMessage = 'Server error. Please retry later.' + errorMessage = this.i18n('Server error. Please retry later.') } errorMessage = errorMessage ? errorMessage : 'Unknown error.' -- cgit v1.2.3