forked from MapComplete/MapComplete
Add current location in localstorage, fixes #13
This commit is contained in:
parent
2a61ae6e1f
commit
89b78ee709
5 changed files with 28 additions and 25 deletions
|
@ -1,24 +1,7 @@
|
|||
import {UIEventSource} from "../UIEventSource";
|
||||
import {OsmConnection} from "../../Logic/OsmConnection";
|
||||
import {LocalStorageSource} from "../../Logic/LocalStorageSource";
|
||||
|
||||
|
||||
export default class Locale {
|
||||
public static language: UIEventSource<string> = Locale.getInitialLanguage();
|
||||
|
||||
private static getInitialLanguage() {
|
||||
// The key to save in local storage
|
||||
const LANGUAGE_KEY = 'language'
|
||||
|
||||
const lng = new UIEventSource("en");
|
||||
const saved = localStorage.getItem(LANGUAGE_KEY);
|
||||
lng.setData(saved);
|
||||
|
||||
|
||||
lng.addCallback(data => {
|
||||
console.log("Selected language", data);
|
||||
localStorage.setItem(LANGUAGE_KEY, data)
|
||||
});
|
||||
|
||||
return lng;
|
||||
}
|
||||
public static language: UIEventSource<string> = LocalStorageSource.Get('language', "en");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue