diff options
Diffstat (limited to 'client/src/app/core')
-rw-r--r-- | client/src/app/core/server/server.service.ts | 20 |
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' | |||
2 | import { HttpClient } from '@angular/common/http' | 2 | import { HttpClient } from '@angular/common/http' |
3 | import { Inject, Injectable, LOCALE_ID } from '@angular/core' | 3 | import { Inject, Injectable, LOCALE_ID } from '@angular/core' |
4 | import { peertubeLocalStorage } from '@app/shared/misc/peertube-local-storage' | 4 | import { peertubeLocalStorage } from '@app/shared/misc/peertube-local-storage' |
5 | import { Observable, ReplaySubject } from 'rxjs' | 5 | import { Observable, ReplaySubject, of } from 'rxjs' |
6 | import { ServerConfig } from '../../../../../shared' | 6 | import { getCompleteLocale, ServerConfig } from '../../../../../shared' |
7 | import { About } from '../../../../../shared/models/server/about.model' | 7 | import { About } from '../../../../../shared/models/server/about.model' |
8 | import { environment } from '../../../environments/environment' | 8 | import { environment } from '../../../environments/environment' |
9 | import { VideoConstant, VideoPrivacy } from '../../../../../shared/models/videos' | 9 | import { VideoConstant, VideoPrivacy } from '../../../../../shared/models/videos' |
10 | import { buildFileLocale, getDefaultLocale } from '../../../../../shared/models/i18n' | 10 | import { isDefaultLocale } from '../../../../../shared/models/i18n' |
11 | import { peertubeTranslate } from '@app/shared/i18n/i18n-utils' | 11 | import { getDevLocale, isOnDevLocale, peertubeTranslate } from '@app/shared/i18n/i18n-utils' |
12 | 12 | ||
13 | @Injectable() | 13 | @Injectable() |
14 | export class ServerService { | 14 | export 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 | ||