Add current location in localstorage, fixes #13

This commit is contained in:
Pieter Vander Vennet 2020-07-24 17:53:09 +02:00
parent 2a61ae6e1f
commit 89b78ee709
5 changed files with 28 additions and 25 deletions

View file

@ -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");
}