fix i18n iframe
This commit is contained in:
parent
bb857d58cc
commit
95c4be6536
@ -3,6 +3,7 @@ import { HttpClient } from '@angular/common/http';
|
||||
import { environment } from '../../environments/environment';
|
||||
import { MatPaginatorIntl } from '@angular/material/paginator';
|
||||
import { Subject, firstValueFrom } from 'rxjs';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
@ -13,9 +14,8 @@ export class I18nService {
|
||||
locales: any = [ "de-informal" ];
|
||||
i18n: any;
|
||||
|
||||
constructor(private http: HttpClient) {
|
||||
|
||||
}
|
||||
constructor(private http: HttpClient,
|
||||
private route: ActivatedRoute) { }
|
||||
|
||||
getLocales() {
|
||||
return this.locales;
|
||||
@ -41,7 +41,9 @@ export class I18nService {
|
||||
let locale = browserLocale || this.locales[ 0 ];
|
||||
try {
|
||||
locale = localStorage.getItem("bstly.locale") || locale;
|
||||
} catch { }
|
||||
} catch {
|
||||
locale = window.location.search.split("locale=")[ 1 ];
|
||||
}
|
||||
|
||||
if (locale == 'de') {
|
||||
locale = 'de-informal';
|
||||
@ -59,7 +61,6 @@ export class I18nService {
|
||||
}
|
||||
|
||||
this.setLocale(locale);
|
||||
|
||||
}
|
||||
|
||||
get(key, args: string[]): string {
|
||||
|
@ -8,7 +8,7 @@ import { fromEvent } from 'rxjs';
|
||||
import { AuthService } from '../../services/auth.service';
|
||||
import { I18nService } from '../../services/i18n.service';
|
||||
import { ProfileService } from '../../services/profile.service';
|
||||
import { MatSidenav } from '@angular/material/sidenav';
|
||||
import { Location } from '@angular/common';
|
||||
|
||||
@Component({
|
||||
selector: 'app-main',
|
||||
@ -36,6 +36,7 @@ export class MainComponent {
|
||||
private router: Router,
|
||||
private iconRegistry: MatIconRegistry,
|
||||
private sanitizer: DomSanitizer,
|
||||
private location: Location,
|
||||
private _adapter: DateAdapter<any>) {
|
||||
iconRegistry.addSvgIcon('logo', sanitizer.bypassSecurityTrustResourceUrl('assets/icons/logo.svg'));
|
||||
}
|
||||
@ -71,7 +72,9 @@ export class MainComponent {
|
||||
setLocale(locale) {
|
||||
try {
|
||||
localStorage.setItem("bstly.locale", locale);
|
||||
} catch { }
|
||||
} catch {
|
||||
this.location.replaceState(window.location.pathname, 'locale=' + locale);
|
||||
}
|
||||
|
||||
if (this.auth && this.auth.authenticated) {
|
||||
this.profileService.getField("locale").subscribe({
|
||||
|
Loading…
Reference in New Issue
Block a user