- return this.http.get(ServerService.BASE_VIDEO_URL + attributeName)
- .subscribe(data => {
- Object.keys(data)
- .forEach(dataKey => {
- hashToPopulate.push({
- id: parseInt(dataKey, 10),
- label: data[dataKey]
- })
- })
-
- if (sort === true) {
- hashToPopulate.sort((a, b) => {
- if (a.label < b.label) return -1
- if (a.label === b.label) return 0
- return 1
- })
- }
-
- notifier.next(true)
- })
+ this.localeObservable
+ .pipe(
+ switchMap(translations => {
+ return this.http.get(ServerService.BASE_VIDEO_URL + attributeName)
+ .pipe(map(data => ({ data, translations })))
+ })
+ )
+ .subscribe(({ data, translations }) => {
+ Object.keys(data)
+ .forEach(dataKey => {
+ const label = data[ dataKey ]
+
+ hashToPopulate.push({
+ id: dataKey,
+ label: peertubeTranslate(label, translations)
+ })
+ })
+
+ if (sort === true) {
+ hashToPopulate.sort((a, b) => {
+ if (a.label < b.label) return -1
+ if (a.label === b.label) return 0
+ return 1
+ })
+ }
+
+ notifier.next(true)
+ })
+ }
+
+ private loadServerLocale () {
+ const completeLocale = isOnDevLocale() ? getDevLocale() : getCompleteLocale(this.localeId)
+
+ // Default locale, nothing to translate
+ if (isDefaultLocale(completeLocale)) {
+ this.localeObservable = of({}).pipe(share())
+ return
+ }
+
+ this.localeObservable = this.http
+ .get(ServerService.BASE_LOCALE_URL + completeLocale + '/server.json')
+ .pipe(share())