2020-11-05 13:34:48 +01:00
|
|
|
import {DropDown} from "./Input/DropDown";
|
|
|
|
import Locale from "./i18n/Locale";
|
2021-06-12 02:58:32 +02:00
|
|
|
import BaseUIElement from "./BaseUIElement";
|
2020-11-05 13:34:48 +01:00
|
|
|
|
|
|
|
export default class LanguagePicker {
|
2021-09-09 00:05:51 +02:00
|
|
|
|
2020-11-05 13:34:48 +01:00
|
|
|
|
|
|
|
public static CreateLanguagePicker(
|
2021-09-09 00:05:51 +02:00
|
|
|
languages: string[],
|
2021-06-12 02:58:32 +02:00
|
|
|
label: string | BaseUIElement = "") {
|
2020-11-05 13:34:48 +01:00
|
|
|
|
|
|
|
if (languages.length <= 1) {
|
|
|
|
return undefined;
|
|
|
|
}
|
2021-09-09 00:05:51 +02:00
|
|
|
|
2021-02-20 03:29:55 +01:00
|
|
|
return new DropDown(label, languages.map(lang => {
|
2020-11-05 13:34:48 +01:00
|
|
|
return {value: lang, shown: lang}
|
|
|
|
}
|
2021-06-14 17:42:26 +02:00
|
|
|
), Locale.language);
|
2020-11-05 13:34:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|