upfix localstorage iframe
This commit is contained in:
@@ -37,31 +37,43 @@ export class I18nService {
|
||||
browserLocale = browserLocale.split("-")[ 0 ];
|
||||
}
|
||||
|
||||
let locale = localStorage.getItem("bstly.locale") || browserLocale || this.locales[ 0 ];
|
||||
let locale = browserLocale || this.locales[ 0 ];
|
||||
try {
|
||||
locale = localStorage.getItem("bstly.locale") || locale;
|
||||
} catch { }
|
||||
|
||||
if (locale == 'de') {
|
||||
locale = 'de-informal';
|
||||
}
|
||||
|
||||
try {
|
||||
await this.http.get(environment.apiUrl + "/i18n").toPromise().then((response: any) => {
|
||||
this.locales = response;
|
||||
});
|
||||
} catch (e) {
|
||||
console.debug("fallback to default locales");
|
||||
}
|
||||
await this.http.get(environment.apiUrl + "/i18n").subscribe({
|
||||
next: (data: any) => {
|
||||
console.log("fetch3", data);
|
||||
this.locales = data;
|
||||
}, error: (error) => {
|
||||
console.debug("fallback to default locales");
|
||||
}
|
||||
});
|
||||
|
||||
if (this.locales.indexOf(locale) == -1) {
|
||||
locale = this.locales[ 0 ];
|
||||
}
|
||||
|
||||
this.setLocale(locale);
|
||||
try {
|
||||
this.i18n = await this.http.get(environment.apiUrl + "/i18n/" + locale).toPromise();
|
||||
} catch (e) {
|
||||
this.i18n = await this.http.get("/assets/i18n/" + locale + ".json").toPromise();
|
||||
console.debug("fallback to default 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) => {
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
get(key, args: string[]): string {
|
||||
@@ -72,7 +84,7 @@ export class I18nService {
|
||||
return this.getInternal(key, args, this.i18n, "", false);
|
||||
}
|
||||
|
||||
getInternal(key, args: string[], from, path, empty : boolean): string {
|
||||
getInternal(key, args: string[], from, path, empty: boolean): string {
|
||||
key += '';
|
||||
if (!from) {
|
||||
return empty ? this.empty(key, args, path) : (key || "");
|
||||
|
||||
Reference in New Issue
Block a user