mirror of
https://framagit.org/framasoft/framadate/funky-framadate-front.git
synced 2023-08-25 13:53:14 +02:00
⚡ 👽 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';
|
import {PollUtilities} from '../config/PollUtilities';
|
||||||
|
|
||||||
const LocalstoragePreferences = {
|
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,
|
@Inject(DOCUMENT) private document,
|
||||||
private route: Router) {
|
private route: Router) {
|
||||||
|
|
||||||
this.translate.setDefaultLang(this.currentLang);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
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) {
|
switchLanguage(language: string) {
|
||||||
this.translate.use(language);
|
if (this.langsAvailable.includes(language)) {
|
||||||
this.currentLang = 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