snappymail/dev/Stores/Language.js

41 lines
1.1 KiB
JavaScript
Raw Normal View History

import ko from 'ko';
import {isArray} from 'Common/Utils';
import * as Settings from 'Storage/Settings';
class LanguageStore
2016-06-30 08:02:45 +08:00
{
constructor() {
this.languages = ko.observableArray([]);
this.languagesAdmin = ko.observableArray([]);
this.language = ko.observable('')
.extend({limitedList: this.languages})
.extend({reversible: true});
2015-03-28 06:06:56 +08:00
this.languageAdmin = ko.observable('')
.extend({limitedList: this.languagesAdmin})
.extend({reversible: true});
2015-03-28 06:06:56 +08:00
this.userLanguage = ko.observable('');
this.userLanguageAdmin = ko.observable('');
}
populate() {
const
aLanguages = Settings.appSettingsGet('languages'),
aLanguagesAdmin = Settings.appSettingsGet('languagesAdmin');
2015-03-16 21:54:56 +08:00
this.languages(isArray(aLanguages) ? aLanguages : []);
this.languagesAdmin(isArray(aLanguagesAdmin) ? aLanguagesAdmin : []);
2015-03-28 06:06:56 +08:00
this.language(Settings.settingsGet('Language'));
this.languageAdmin(Settings.settingsGet('LanguageAdmin'));
this.userLanguage(Settings.settingsGet('UserLanguage'));
this.userLanguageAdmin(Settings.settingsGet('UserLanguageAdmin'));
}
}
2016-06-30 08:02:45 +08:00
module.exports = new LanguageStore();