aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/core/server/server.service.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/core/server/server.service.ts')
-rw-r--r--client/src/app/core/server/server.service.ts20
1 files changed, 11 insertions, 9 deletions
diff --git a/client/src/app/core/server/server.service.ts b/client/src/app/core/server/server.service.ts
index 56d33339e..74363e6a1 100644
--- a/client/src/app/core/server/server.service.ts
+++ b/client/src/app/core/server/server.service.ts
@@ -2,13 +2,13 @@ import { map, share, switchMap, tap } from 'rxjs/operators'
2import { HttpClient } from '@angular/common/http' 2import { HttpClient } from '@angular/common/http'
3import { Inject, Injectable, LOCALE_ID } from '@angular/core' 3import { Inject, Injectable, LOCALE_ID } from '@angular/core'
4import { peertubeLocalStorage } from '@app/shared/misc/peertube-local-storage' 4import { peertubeLocalStorage } from '@app/shared/misc/peertube-local-storage'
5import { Observable, ReplaySubject } from 'rxjs' 5import { Observable, ReplaySubject, of } from 'rxjs'
6import { ServerConfig } from '../../../../../shared' 6import { getCompleteLocale, ServerConfig } from '../../../../../shared'
7import { About } from '../../../../../shared/models/server/about.model' 7import { About } from '../../../../../shared/models/server/about.model'
8import { environment } from '../../../environments/environment' 8import { environment } from '../../../environments/environment'
9import { VideoConstant, VideoPrivacy } from '../../../../../shared/models/videos' 9import { VideoConstant, VideoPrivacy } from '../../../../../shared/models/videos'
10import { buildFileLocale, getDefaultLocale } from '../../../../../shared/models/i18n' 10import { isDefaultLocale } from '../../../../../shared/models/i18n'
11import { peertubeTranslate } from '@app/shared/i18n/i18n-utils' 11import { getDevLocale, isOnDevLocale, peertubeTranslate } from '@app/shared/i18n/i18n-utils'
12 12
13@Injectable() 13@Injectable()
14export class ServerService { 14export class ServerService {
@@ -72,8 +72,8 @@ export class ServerService {
72 private http: HttpClient, 72 private http: HttpClient,
73 @Inject(LOCALE_ID) private localeId: string 73 @Inject(LOCALE_ID) private localeId: string
74 ) { 74 ) {
75 this.loadConfigLocally()
76 this.loadServerLocale() 75 this.loadServerLocale()
76 this.loadConfigLocally()
77 } 77 }
78 78
79 loadConfig () { 79 loadConfig () {
@@ -163,14 +163,16 @@ export class ServerService {
163 } 163 }
164 164
165 private loadServerLocale () { 165 private loadServerLocale () {
166 const fileLocale = buildFileLocale(environment.production === true ? this.localeId : 'fr') 166 const completeLocale = isOnDevLocale() ? getDevLocale() : getCompleteLocale(this.localeId)
167 167
168 // Default locale, nothing to translate 168 // Default locale, nothing to translate
169 const defaultFileLocale = buildFileLocale(getDefaultLocale()) 169 if (isDefaultLocale(completeLocale)) {
170 if (fileLocale === defaultFileLocale) return {} 170 this.localeObservable = of({}).pipe(share())
171 return
172 }
171 173
172 this.localeObservable = this.http 174 this.localeObservable = this.http
173 .get(ServerService.BASE_LOCALE_URL + fileLocale + '/server.json') 175 .get(ServerService.BASE_LOCALE_URL + completeLocale + '/server.json')
174 .pipe(share()) 176 .pipe(share())
175 } 177 }
176 178