snappymail/dev/Stores/Language.js
djmaze aeb5275648 Improved boot.js with existing global window.rl
Put dev/Storage/Settings.js in boots.js global rl.settings
2020-09-04 12:05:17 +02:00

38 lines
1 KiB
JavaScript

import ko from 'ko';
class LanguageStore {
constructor() {
this.languages = ko.observableArray([]);
this.languagesAdmin = ko.observableArray([]);
this.language = ko
.observable('')
.extend({ limitedList: this.languages })
.extend({ reversible: true });
this.languageAdmin = ko
.observable('')
.extend({ limitedList: this.languagesAdmin })
.extend({ reversible: true });
this.userLanguage = ko.observable('');
this.userLanguageAdmin = ko.observable('');
}
populate() {
const Settings = rl.settings,
aLanguages = Settings.app('languages'),
aLanguagesAdmin = Settings.app('languagesAdmin');
this.languages(Array.isArray(aLanguages) ? aLanguages : []);
this.languagesAdmin(Array.isArray(aLanguagesAdmin) ? aLanguagesAdmin : []);
this.language(Settings.get('Language'));
this.languageAdmin(Settings.get('LanguageAdmin'));
this.userLanguage(Settings.get('UserLanguage'));
this.userLanguageAdmin(Settings.get('UserLanguageAdmin'));
}
}
export default new LanguageStore();