This commit is contained in:
2019-01-03 18:25:41 +00:00
parent 1e6eb7ca1a
commit a890bdeeb6
68 changed files with 35812 additions and 0 deletions

43
ayanova/src/api/locale.js Normal file
View File

@@ -0,0 +1,43 @@
/* xeslint-disable */
import store from "../store";
import apiUtil from "./apiutil";
import _ from "../utils/libs/lodash.js";
export default {
get(key) {
// debugger;
if (!_.has(store.state.localeText, key)) {
return "?" + key + "?";
}
return store.state.localeText[key];
},
fetch(keys) {
return new Promise(function(resolve, reject) {
//step 1: build an array of keys that we don't have already
//Note: this will ensure only unique keys go into the store so it's safe to call this with dupes as can happen
var needIt = [];
for (var i = 0; i < keys.length; i++) {
if (!_.has(store.state.localeText, keys[i])) {
needIt.push(keys[i]);
}
}
if (needIt.length == 0) {
resolve();
return;
}
//step 2: get it
fetch(apiUtil.APIUrl("locale/subset"), apiUtil.fetchPostOptions(needIt))
.then(apiUtil.status)
.then(apiUtil.json)
.then(response => {
_.forEach(response.data, function(item) {
store.commit("addLocaleText", item);
});
resolve();
})
.catch(function(error) {
reject(error);
});
});
}
};