2016-08-17 06:01:20 +08:00
|
|
|
import ko from 'ko';
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2021-01-26 05:00:13 +08:00
|
|
|
import { convertLangName } from 'Common/Translator';
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2021-01-24 17:25:23 +08:00
|
|
|
import { AbstractViewPopup } from 'Knoin/AbstractViews';
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2022-02-24 21:01:41 +08:00
|
|
|
export class LanguagesPopupView extends AbstractViewPopup {
|
2016-08-17 06:01:20 +08:00
|
|
|
constructor() {
|
2021-01-24 17:25:23 +08:00
|
|
|
super('Languages');
|
2016-08-17 06:01:20 +08:00
|
|
|
this.fLang = null;
|
2023-02-21 18:53:43 +08:00
|
|
|
this.languages = ko.observableArray();
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
onShow(fLanguage, langs, userLanguage) {
|
|
|
|
this.fLang = fLanguage;
|
2023-02-21 18:53:43 +08:00
|
|
|
this.languages(langs.map(language => ({
|
|
|
|
key: language,
|
|
|
|
user: userLanguage === language,
|
|
|
|
selected: fLanguage?.() === language,
|
|
|
|
fullName: convertLangName(language),
|
|
|
|
title: convertLangName(language, true)
|
|
|
|
})));
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
changeLanguage(lang) {
|
2022-09-02 17:52:07 +08:00
|
|
|
this.fLang?.(lang);
|
2022-03-04 16:21:24 +08:00
|
|
|
this.close();
|
2016-06-30 08:02:45 +08:00
|
|
|
}
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|