forked from MapComplete/MapComplete
Translations
This commit is contained in:
parent
615bbec05d
commit
369c19a58a
34 changed files with 287 additions and 173 deletions
|
@ -1,18 +1,24 @@
|
|||
import { UIEventSource } from "../UIEventSource";
|
||||
import {UIEventSource} from "../UIEventSource";
|
||||
import {OsmConnection} from "../../Logic/OsmConnection";
|
||||
|
||||
|
||||
const LANGUAGE_KEY = 'language'
|
||||
|
||||
export default class Locale {
|
||||
public static language: UIEventSource<string> = new UIEventSource(Locale.getInitialLanguage())
|
||||
|
||||
public static init() {
|
||||
Locale.language.addCallback(data => {
|
||||
localStorage.setItem(LANGUAGE_KEY, data)
|
||||
})
|
||||
}
|
||||
public static language: UIEventSource<string> = Locale.getInitialLanguage()
|
||||
|
||||
private static getInitialLanguage() {
|
||||
return localStorage.getItem(LANGUAGE_KEY)
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue