Skip to content

Commit

Permalink
Bug in the language switcher and the language itself mathkruger#73
Browse files Browse the repository at this point in the history
  • Loading branch information
francesco-buscicchio committed Jul 13, 2023
1 parent ab324af commit f7670cb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { SelectPlaylistComponent } from "./pages/select-playlist/select-playlist
import { PodcastsComponent } from './pages/podcasts/podcasts.component';
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { LanguageSwitcherComponent,WindowProvider } from './components/language-switcher/language-switcher.component';
import { LanguageSwitcherComponent } from './components/language-switcher/language-switcher.component';
import { VolumeBoxComponent } from './components/volume-box/volume-box.component';
import { SettingsComponent } from './pages/settings/settings.component';
import { YoutubePlayerComponent } from './components/youtube-player/youtube-player.component';
Expand Down Expand Up @@ -97,7 +97,7 @@ import { MatInputModule } from '@angular/material/input';
],
providers: [
{ provide: HTTP_INTERCEPTORS, useClass: TokenVerificationInterceptorService, multi: true },
PipesModule,WindowProvider
PipesModule
],
bootstrap: [AppComponent]
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import { Injectable, Inject } from '@angular/core';
})
export class LanguageSwitcherComponent implements OnInit {

constructor(public translate: TranslateService, @Inject('WINDOW') private window: Window) { }
constructor(public translate: TranslateService) { }

currentLang: any;
languages: any[] = [];
hidden: boolean = true;

ngOnInit() {
const defaultLanguage = window.localStorage.getItem("languageSelected") || this.window.navigator.language.slice(0,2);
const defaultLanguage = window.localStorage.getItem("languageSelected") || window.navigator.language.slice(0,2);



Expand Down Expand Up @@ -54,9 +54,3 @@ export class LanguageSwitcherComponent implements OnInit {
window.localStorage.setItem('languageSelected', lang.code);
}
}

export const WindowProvider = [{ provide: "WINDOW", useFactory: getWindow }];

export function getWindow(): Window {
return window;
}

0 comments on commit f7670cb

Please sign in to comment.