forked from MapComplete/MapComplete
Huge refactoring (WIP)
This commit is contained in:
parent
62c4f0a928
commit
895aa132ec
55 changed files with 1177 additions and 2190 deletions
|
@ -1,11 +1,13 @@
|
|||
import {UIEventSource} from "../../Logic/UIEventSource";
|
||||
import {UIElement} from "../UIElement";
|
||||
import {LocalStorageSource} from "../../Logic/Web/LocalStorageSource";
|
||||
import {DropDown} from "../Input/DropDown";
|
||||
|
||||
|
||||
export default class Locale {
|
||||
|
||||
public static language: UIEventSource<string> = Locale.setup();
|
||||
|
||||
private static setup() {
|
||||
const source = LocalStorageSource.Get('language', "en");
|
||||
if (!UIElement.runningFromConsole) {
|
||||
|
@ -17,6 +19,20 @@ export default class Locale {
|
|||
return source;
|
||||
}
|
||||
|
||||
public static CreateLanguagePicker(
|
||||
languages : string[] ,
|
||||
label: string | UIElement = "") {
|
||||
|
||||
if (languages.length <= 1) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return new DropDown(label, languages.map(lang => {
|
||||
return {value: lang, shown: lang}
|
||||
}
|
||||
), Locale.language);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue