mapcomplete/UI/i18n/Locale.ts

19 lines
459 B
TypeScript
Raw Normal View History

2020-07-20 12:39:43 +02:00
import { UIEventSource } from "../UIEventSource";
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)
})
}
private static getInitialLanguage() {
return localStorage.getItem(LANGUAGE_KEY)
}
}