fix i18n
This commit is contained in:
parent
d68060b3fb
commit
bb857d58cc
@ -69,9 +69,7 @@ import { JukeboxComponent } from './pages/jukebox/jukebox.compontent';
|
||||
|
||||
|
||||
export function init_app(i18n: I18nService) {
|
||||
return () => {
|
||||
i18n.fetch();
|
||||
};
|
||||
return () => i18n.fetch()
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
|
@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { environment } from '../../environments/environment';
|
||||
import { MatPaginatorIntl } from '@angular/material/paginator';
|
||||
import { Subject } from 'rxjs';
|
||||
import { Subject, firstValueFrom } from 'rxjs';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
@ -10,7 +10,7 @@ import { Subject } from 'rxjs';
|
||||
export class I18nService {
|
||||
|
||||
locale: string = "de-informal";
|
||||
locales: any[] = [ "de-informal" ];
|
||||
locales: any = [ "de-informal" ];
|
||||
i18n: any;
|
||||
|
||||
constructor(private http: HttpClient) {
|
||||
@ -30,12 +30,7 @@ export class I18nService {
|
||||
}
|
||||
|
||||
async fetch() {
|
||||
|
||||
await this.http.get(environment.apiUrl + "/i18n").subscribe({
|
||||
next: (data: any) => {
|
||||
this.locales = data;
|
||||
}, error: (error) => { }
|
||||
});
|
||||
this.locales = await firstValueFrom(this.http.get(environment.apiUrl + "/i18n"));
|
||||
|
||||
let browserLocale = window.navigator.language || window.parent.navigator.language;
|
||||
|
||||
@ -56,20 +51,14 @@ export class I18nService {
|
||||
locale = this.locales[ 0 ];
|
||||
}
|
||||
|
||||
this.setLocale(locale);
|
||||
await this.http.get(environment.apiUrl + "/i18n/" + locale).subscribe({
|
||||
next: (data: any) => {
|
||||
this.i18n = data;
|
||||
}, error: async (error) => {
|
||||
await this.http.get("/assets/i18n/" + locale + ".json").subscribe({
|
||||
next: (data: any) => {
|
||||
this.i18n = data;
|
||||
}, error: (error) => {
|
||||
|
||||
try {
|
||||
this.i18n = await firstValueFrom(this.http.get(environment.apiUrl + "/i18n/" + locale));
|
||||
} catch {
|
||||
this.i18n = await firstValueFrom(this.http.get("/assets/i18n/" + locale + ".json"));
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
this.setLocale(locale);
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user