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