snappymail/dev/Stores/Language.js

37 lines
994 B
JavaScript
Raw Normal View History

import ko from 'ko';
2019-07-05 03:19:24 +08:00
class LanguageStore {
constructor() {
this.languages = ko.observableArray();
this.languagesAdmin = ko.observableArray();
2019-07-05 03:19:24 +08:00
this.language = ko
.observable('')
2020-10-27 18:09:24 +08:00
.extend({ limitedList: this.languages, reversible: true });
2015-03-28 06:06:56 +08:00
2019-07-05 03:19:24 +08:00
this.languageAdmin = ko
.observable('')
2020-10-27 18:09:24 +08:00
.extend({ limitedList: this.languagesAdmin, reversible: true });
2015-03-28 06:06:56 +08:00
this.userLanguage = ko.observable('');
this.userLanguageAdmin = ko.observable('');
}
populate() {
const Settings = rl.settings,
aLanguages = Settings.app('languages'),
aLanguagesAdmin = Settings.app('languagesAdmin');
2015-03-16 21:54:56 +08:00
this.languages(Array.isArray(aLanguages) ? aLanguages : []);
this.languagesAdmin(Array.isArray(aLanguagesAdmin) ? aLanguagesAdmin : []);
2015-03-28 06:06:56 +08:00
this.language(Settings.get('Language'));
this.languageAdmin(Settings.get('LanguageAdmin'));
this.userLanguage(Settings.get('UserLanguage'));
this.userLanguageAdmin(Settings.get('UserLanguageAdmin'));
}
}
export default new LanguageStore();