forked from tykayn/funky-framadate-front
⚡ 👽 Conserver le choix de langue au rechargement de la page - issue #54
This commit is contained in:
parent
936110846c
commit
acb091802c
@ -10,7 +10,9 @@ import {mockSuccessVote} from '../config/mocks/mock-success-vote';
|
||||
import {PollUtilities} from '../config/PollUtilities';
|
||||
|
||||
const LocalstoragePreferences = {
|
||||
themeName: 'light-watermelon'
|
||||
themeName: 'light-watermelon',
|
||||
themeClass: 'theme-light-watermelon',
|
||||
lang: 'fr',
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -26,15 +26,29 @@ export class LanguageComponent implements OnInit {
|
||||
@Inject(DOCUMENT) private document,
|
||||
private route: Router) {
|
||||
|
||||
this.translate.setDefaultLang(this.currentLang);
|
||||
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
console.log('this.config.preferences', this.config.preferences)
|
||||
if (this.config.preferences.lang) {
|
||||
this.switchLanguage(this.config.preferences.lang);
|
||||
} else {
|
||||
this.switchLanguage(this.currentLang);
|
||||
}
|
||||
}
|
||||
|
||||
switchLanguage(language: string) {
|
||||
if (this.langsAvailable.includes(language)) {
|
||||
|
||||
this.translate.use(language);
|
||||
this.currentLang = language;
|
||||
this.config.setPreference('lang', language);
|
||||
this.translate.setDefaultLang(this.currentLang);
|
||||
|
||||
} else {
|
||||
console.error('this lang is not supported');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user