2016-08-17 06:01:20 +08:00
|
|
|
import ko from 'ko';
|
|
|
|
import * as Settings from 'Storage/Settings';
|
2015-01-27 05:06:00 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
class LanguageStore {
|
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
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
this.language = ko
|
|
|
|
.observable('')
|
|
|
|
.extend({ limitedList: this.languages })
|
|
|
|
.extend({ reversible: true });
|
2015-03-28 06:06:56 +08:00
|
|
|
|
2019-07-05 03:19:24 +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() {
|
2019-07-05 03:19:24 +08:00
|
|
|
const aLanguages = Settings.appSettingsGet('languages'),
|
2016-08-17 06:01:20 +08:00
|
|
|
aLanguagesAdmin = Settings.appSettingsGet('languagesAdmin');
|
2015-03-16 21:54:56 +08:00
|
|
|
|
2020-07-30 03:49:41 +08:00
|
|
|
this.languages(Array.isArray(aLanguages) ? aLanguages : []);
|
|
|
|
this.languagesAdmin(Array.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();
|