aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/core/auth
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-08-12 10:40:04 +0200
committerChocobozzz <me@florianbigard.com>2020-08-14 10:28:30 +0200
commit66357162f8e1227495f09bd4f68446aad7071c6d (patch)
tree7d4429506deb512b2fe1d0267f38a28cda20af55 /client/src/app/core/auth
parent8c360747995e17eb5520e22fc3d7bd4c3d26eeee (diff)
downloadPeerTube-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/auth')
-rw-r--r--client/src/app/core/auth/auth.service.ts24
1 files changed, 10 insertions, 14 deletions
diff --git a/client/src/app/core/auth/auth.service.ts b/client/src/app/core/auth/auth.service.ts
index d3dc48267..10e2c2c58 100644
--- a/client/src/app/core/auth/auth.service.ts
+++ b/client/src/app/core/auth/auth.service.ts
@@ -6,7 +6,6 @@ import { Injectable } from '@angular/core'
6import { Router } from '@angular/router' 6import { Router } from '@angular/router'
7import { Notifier } from '@app/core/notification/notifier.service' 7import { Notifier } from '@app/core/notification/notifier.service'
8import { objectToUrlEncoded, peertubeLocalStorage } from '@root-helpers/index' 8import { objectToUrlEncoded, peertubeLocalStorage } from '@root-helpers/index'
9import { I18n } from '@ngx-translate/i18n-polyfill'
10import { MyUser as UserServerModel, OAuthClientLocal, User, UserLogin, UserRefreshToken } from '@shared/models' 9import { MyUser as UserServerModel, OAuthClientLocal, User, UserLogin, UserRefreshToken } from '@shared/models'
11import { environment } from '../../../environments/environment' 10import { environment } from '../../../environments/environment'
12import { RestExtractor } from '../rest/rest-extractor.service' 11import { RestExtractor } from '../rest/rest-extractor.service'
@@ -48,9 +47,8 @@ export class AuthService {
48 private notifier: Notifier, 47 private notifier: Notifier,
49 private hotkeysService: HotkeysService, 48 private hotkeysService: HotkeysService,
50 private restExtractor: RestExtractor, 49 private restExtractor: RestExtractor,
51 private router: Router, 50 private router: Router
52 private i18n: I18n 51 ) {
53 ) {
54 this.loginChanged = new Subject<AuthStatus>() 52 this.loginChanged = new Subject<AuthStatus>()
55 this.loginChangedSource = this.loginChanged.asObservable() 53 this.loginChangedSource = this.loginChanged.asObservable()
56 54
@@ -62,19 +60,19 @@ export class AuthService {
62 new Hotkey('m s', (event: KeyboardEvent): boolean => { 60 new Hotkey('m s', (event: KeyboardEvent): boolean => {
63 this.router.navigate([ '/videos/subscriptions' ]) 61 this.router.navigate([ '/videos/subscriptions' ])
64 return false 62 return false
65 }, undefined, this.i18n('Go to my subscriptions')), 63 }, undefined, $localize`Go to my subscriptions`),
66 new Hotkey('m v', (event: KeyboardEvent): boolean => { 64 new Hotkey('m v', (event: KeyboardEvent): boolean => {
67 this.router.navigate([ '/my-account/videos' ]) 65 this.router.navigate([ '/my-account/videos' ])
68 return false 66 return false
69 }, undefined, this.i18n('Go to my videos')), 67 }, undefined, $localize`Go to my videos`),
70 new Hotkey('m i', (event: KeyboardEvent): boolean => { 68 new Hotkey('m i', (event: KeyboardEvent): boolean => {
71 this.router.navigate([ '/my-account/video-imports' ]) 69 this.router.navigate([ '/my-account/video-imports' ])
72 return false 70 return false
73 }, undefined, this.i18n('Go to my imports')), 71 }, undefined, $localize`Go to my imports`),
74 new Hotkey('m c', (event: KeyboardEvent): boolean => { 72 new Hotkey('m c', (event: KeyboardEvent): boolean => {
75 this.router.navigate([ '/my-account/video-channels' ]) 73 this.router.navigate([ '/my-account/video-channels' ])
76 return false 74 return false
77 }, undefined, this.i18n('Go to my channels')) 75 }, undefined, $localize`Go to my channels`)
78 ] 76 ]
79 } 77 }
80 78
@@ -97,14 +95,12 @@ export class AuthService {
97 let errorMessage = error.message 95 let errorMessage = error.message
98 96
99 if (error.status === 403) { 97 if (error.status === 403) {
100 errorMessage = this.i18n('Cannot retrieve OAuth Client credentials: {{errorText}}.\n', { errorText: error.text }) 98 errorMessage = $localize`Cannot retrieve OAuth Client credentials: ${error.text}.
101 errorMessage += this.i18n( 99Ensure you have correctly configured PeerTube (config/ directory), in particular the "webserver" section.`
102 'Ensure you have correctly configured PeerTube (config/ directory), in particular the "webserver" section.'
103 )
104 } 100 }
105 101
106 // We put a bigger timeout: this is an important message 102 // We put a bigger timeout: this is an important message
107 this.notifier.error(errorMessage, this.i18n('Error'), 7000) 103 this.notifier.error(errorMessage, $localize`Error`, 7000)
108 } 104 }
109 ) 105 )
110 } 106 }
@@ -216,7 +212,7 @@ export class AuthService {
216 this.router.navigate([ '/login' ]) 212 this.router.navigate([ '/login' ])
217 213
218 return observableThrowError({ 214 return observableThrowError({
219 error: this.i18n('You need to reconnect.') 215 error: $localize`You need to reconnect.`
220 }) 216 })
221 }), 217 }),
222 share() 218 share()