- this.localeObservable
- .pipe(
- switchMap(translations => {
- return this.http.get<{ [id: string]: string }>(baseUrl + attributeName)
- .pipe(map(data => ({ data, translations })))
- })
- )
- .subscribe(({ data, translations }) => {
- Object.keys(data)
- .forEach(dataKey => {
- const label = data[ dataKey ]
-
- hashToPopulate.push({
- id: attributeName === 'languages' ? dataKey : parseInt(dataKey, 10),
- label: peertubeTranslate(label, translations)
- })
- })
-
- if (sort === true) sortBy(hashToPopulate, 'label')
-
- notifier.next(true)
- })
- }
-
- private loadServerLocale () {
- const completeLocale = isOnDevLocale() ? getDevLocale() : getCompleteLocale(this.localeId)
-
- // Default locale, nothing to translate
- if (isDefaultLocale(completeLocale)) {
- this.localeObservable = of({}).pipe(shareReplay())
- return
- }
+ return this.getServerLocale()
+ .pipe(
+ switchMap(translations => {
+ return this.http.get<{ [ id: string ]: string }>(baseUrl + attributeName)
+ .pipe(map(data => ({ data, translations })))
+ }),
+ map(({ data, translations }) => {
+ const hashToPopulate: VideoConstant<T>[] = []
+
+ Object.keys(data)
+ .forEach(dataKey => {
+ const label = data[ dataKey ]
+
+ hashToPopulate.push({
+ id: (attributeName === 'languages' ? dataKey : parseInt(dataKey, 10)) as T,
+ label: peertubeTranslate(label, translations)
+ })
+ })
+
+ if (sort === true) sortBy(hashToPopulate, 'label')