2016-08-17 06:01:20 +08:00
|
|
|
import ko from 'ko';
|
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() {
|
2021-01-22 19:23:20 +08:00
|
|
|
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('')
|
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
|
|
|
|
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() {
|
2020-09-04 18:05:17 +08:00
|
|
|
const Settings = rl.settings,
|
|
|
|
aLanguages = Settings.app('languages'),
|
|
|
|
aLanguagesAdmin = Settings.app('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
|
|
|
|
2020-09-04 18:05:17 +08:00
|
|
|
this.language(Settings.get('Language'));
|
|
|
|
this.languageAdmin(Settings.get('LanguageAdmin'));
|
2015-01-27 05:06:00 +08:00
|
|
|
|
2020-09-04 18:05:17 +08:00
|
|
|
this.userLanguage(Settings.get('UserLanguage'));
|
|
|
|
this.userLanguageAdmin(Settings.get('UserLanguageAdmin'));
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
|
|
|
}
|
2015-01-27 05:06:00 +08:00
|
|
|
|
2016-09-13 04:50:21 +08:00
|
|
|
export default new LanguageStore();
|