aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/core/auth/auth.service.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-06-04 16:21:17 +0200
committerChocobozzz <me@florianbigard.com>2018-06-05 08:43:01 +0200
commitb1d40cff89f7cff565a98cdbcea9a624196a169a (patch)
treed24746c1cc69f50471a9eba0dfb1c1bae06a1870 /client/src/app/core/auth/auth.service.ts
parent989e526abf0c0dd7958deb630df009608561bb67 (diff)
downloadPeerTube-b1d40cff89f7cff565a98cdbcea9a624196a169a.tar.gz
PeerTube-b1d40cff89f7cff565a98cdbcea9a624196a169a.tar.zst
PeerTube-b1d40cff89f7cff565a98cdbcea9a624196a169a.zip
Add i18n attributes
Diffstat (limited to 'client/src/app/core/auth/auth.service.ts')
-rw-r--r--client/src/app/core/auth/auth.service.ts17
1 files changed, 10 insertions, 7 deletions
diff --git a/client/src/app/core/auth/auth.service.ts b/client/src/app/core/auth/auth.service.ts
index 614d38d08..363f58155 100644
--- a/client/src/app/core/auth/auth.service.ts
+++ b/client/src/app/core/auth/auth.service.ts
@@ -1,5 +1,5 @@
1import { Observable, ReplaySubject, Subject, throwError as observableThrowError } from 'rxjs' 1import { Observable, ReplaySubject, Subject, throwError as observableThrowError } from 'rxjs'
2import { catchError, map, mergeMap, tap, share } from 'rxjs/operators' 2import { catchError, map, mergeMap, share, tap } from 'rxjs/operators'
3import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http' 3import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'
4import { Injectable } from '@angular/core' 4import { Injectable } from '@angular/core'
5import { Router } from '@angular/router' 5import { Router } from '@angular/router'
@@ -13,6 +13,7 @@ import { AuthStatus } from './auth-status.model'
13import { AuthUser } from './auth-user.model' 13import { AuthUser } from './auth-user.model'
14import { objectToUrlEncoded } from '@app/shared/misc/utils' 14import { objectToUrlEncoded } from '@app/shared/misc/utils'
15import { peertubeLocalStorage } from '@app/shared/misc/peertube-local-storage' 15import { peertubeLocalStorage } from '@app/shared/misc/peertube-local-storage'
16import { I18n } from '@ngx-translate/i18n-polyfill'
16 17
17interface UserLoginWithUsername extends UserLogin { 18interface UserLoginWithUsername extends UserLogin {
18 access_token: string 19 access_token: string
@@ -46,7 +47,8 @@ export class AuthService {
46 private http: HttpClient, 47 private http: HttpClient,
47 private notificationsService: NotificationsService, 48 private notificationsService: NotificationsService,
48 private restExtractor: RestExtractor, 49 private restExtractor: RestExtractor,
49 private router: Router 50 private router: Router,
51 private i18n: I18n
50 ) { 52 ) {
51 this.loginChanged = new Subject<AuthStatus>() 53 this.loginChanged = new Subject<AuthStatus>()
52 this.loginChangedSource = this.loginChanged.asObservable() 54 this.loginChangedSource = this.loginChanged.asObservable()
@@ -74,14 +76,15 @@ export class AuthService {
74 let errorMessage = error.message 76 let errorMessage = error.message
75 77
76 if (error.status === 403) { 78 if (error.status === 403) {
77 errorMessage = `Cannot retrieve OAuth Client credentials: ${error.text}. \n` 79 errorMessage = this.i18n('Cannot retrieve OAuth Client credentials: {{ errorText }}.\n', { errorText: error.text })
78 errorMessage += 'Ensure you have correctly configured PeerTube (config/ directory), ' + 80 errorMessage += this.i18n(
79 'in particular the "webserver" section.' 81 'Ensure you have correctly configured PeerTube (config/ directory), in particular the "webserver" section.'
82 )
80 } 83 }
81 84
82 // We put a bigger timeout 85 // We put a bigger timeout
83 // This is an important message 86 // This is an important message
84 this.notificationsService.error('Error', errorMessage, { timeOut: 7000 }) 87 this.notificationsService.error(this.i18n('Error'), errorMessage, { timeOut: 7000 })
85 } 88 }
86 ) 89 )
87 } 90 }
@@ -180,7 +183,7 @@ export class AuthService {
180 this.router.navigate([ '/login' ]) 183 this.router.navigate([ '/login' ])
181 184
182 return observableThrowError({ 185 return observableThrowError({
183 error: 'You need to reconnect.' 186 error: this.i18n('You need to reconnect.')
184 }) 187 })
185 }), 188 }),
186 share() 189 share()