diff options
Diffstat (limited to 'client/src/app/shared/instance/instance.service.ts')
-rw-r--r-- | client/src/app/shared/instance/instance.service.ts | 45 |
1 files changed, 28 insertions, 17 deletions
diff --git a/client/src/app/shared/instance/instance.service.ts b/client/src/app/shared/instance/instance.service.ts index 44b413fa4..8b26063fb 100644 --- a/client/src/app/shared/instance/instance.service.ts +++ b/client/src/app/shared/instance/instance.service.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { catchError } from 'rxjs/operators' | 1 | import { catchError, map } from 'rxjs/operators' |
2 | import { HttpClient } from '@angular/common/http' | 2 | import { HttpClient } from '@angular/common/http' |
3 | import { Injectable } from '@angular/core' | 3 | import { Injectable } from '@angular/core' |
4 | import { environment } from '../../../environments/environment' | 4 | import { environment } from '../../../environments/environment' |
@@ -7,6 +7,7 @@ import { About } from '../../../../../shared/models/server' | |||
7 | import { MarkdownService } from '@app/shared/renderer' | 7 | import { MarkdownService } from '@app/shared/renderer' |
8 | import { peertubeTranslate } from '@shared/models' | 8 | import { peertubeTranslate } from '@shared/models' |
9 | import { ServerService } from '@app/core' | 9 | import { ServerService } from '@app/core' |
10 | import { forkJoin } from 'rxjs' | ||
10 | 11 | ||
11 | @Injectable() | 12 | @Injectable() |
12 | export class InstanceService { | 13 | export class InstanceService { |
@@ -57,25 +58,35 @@ export class InstanceService { | |||
57 | return html | 58 | return html |
58 | } | 59 | } |
59 | 60 | ||
60 | buildTranslatedLanguages (about: About, translations: any) { | 61 | buildTranslatedLanguages (about: About) { |
61 | const languagesArray = this.serverService.getVideoLanguages() | 62 | return forkJoin([ |
63 | this.serverService.getVideoLanguages(), | ||
64 | this.serverService.getServerLocale() | ||
65 | ]).pipe( | ||
66 | map(([ languagesArray, translations ]) => { | ||
67 | return about.instance.languages | ||
68 | .map(l => { | ||
69 | const languageObj = languagesArray.find(la => la.id === l) | ||
62 | 70 | ||
63 | return about.instance.languages | 71 | return peertubeTranslate(languageObj.label, translations) |
64 | .map(l => { | 72 | }) |
65 | const languageObj = languagesArray.find(la => la.id === l) | 73 | }) |
66 | 74 | ) | |
67 | return peertubeTranslate(languageObj.label, translations) | ||
68 | }) | ||
69 | } | 75 | } |
70 | 76 | ||
71 | buildTranslatedCategories (about: About, translations: any) { | 77 | buildTranslatedCategories (about: About) { |
72 | const categoriesArray = this.serverService.getVideoCategories() | 78 | return forkJoin([ |
73 | 79 | this.serverService.getVideoCategories(), | |
74 | return about.instance.categories | 80 | this.serverService.getServerLocale() |
75 | .map(c => { | 81 | ]).pipe( |
76 | const categoryObj = categoriesArray.find(ca => ca.id === c) | 82 | map(([ categoriesArray, translations ]) => { |
83 | return about.instance.categories | ||
84 | .map(c => { | ||
85 | const categoryObj = categoriesArray.find(ca => ca.id === c) | ||
77 | 86 | ||
78 | return peertubeTranslate(categoryObj.label, translations) | 87 | return peertubeTranslate(categoryObj.label, translations) |
79 | }) | 88 | }) |
89 | }) | ||
90 | ) | ||
80 | } | 91 | } |
81 | } | 92 | } |