mapcomplete/UI/i18n/Locale.ts
2020-07-20 23:43:42 +02:00

23 lines
724 B
TypeScript

import { UIEventSource } from "../UIEventSource";
import ParkingType from "../../Customizations/Questions/bike/ParkingType";
const LANGUAGE_KEY = 'language'
export default class Locale {
const
public static language: UIEventSource<string> = new UIEventSource(Locale.getInitialLanguage())
public static init() {
Locale.language.addCallback(data => {
localStorage.setItem(LANGUAGE_KEY, data)
if (window.confirm('In order to change the displayed language, the page needs to be reloaded. Reload now?')) {
location.reload()
}
})
}
private static getInitialLanguage() {
return localStorage.getItem(LANGUAGE_KEY) || 'en'
}
}