This commit is contained in:
2019-07-24 15:22:19 +00:00
parent a14e64644d
commit 864c0ebab8
4 changed files with 30 additions and 19 deletions

View File

@@ -1,15 +1,12 @@
/* ZZeslint-disable */
import store from "../store";
import gzapi from "./gzapi";
import _ from "../libs/lodash.min.js";
export default {
get(key) {
// debugger;
if (!_.has(store.state.localeText, key)) {
if (!window.$gz._.has(window.$gz.store.state.localeText, key)) {
return "??" + key;
}
return store.state.localeText[key];
return window.$gz.store.state.localeText[key];
},
fetch(keys) {
return new Promise(function fetchLocaleKeysFromServer(resolve) {
@@ -18,7 +15,7 @@ export default {
//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])) {
if (!window.$gz._.has(window.$gz.store.state.localeText, keys[i])) {
needIt.push(keys[i]);
}
}
@@ -29,13 +26,19 @@ export default {
}
//step 2: get it
fetch(gzapi.APIUrl("locale/subset"), gzapi.fetchPostOptions(needIt))
.then(gzapi.status)
.then(gzapi.json)
fetch(
window.$gz.api.APIUrl("locale/subset"),
window.$gz.api.fetchPostOptions(needIt)
)
.then(window.$gz.api.status)
.then(window.$gz.api.json)
.then(response => {
_.forEach(response.data, function commitFetchedLTItemToStore(item) {
store.commit("addLocaleText", item);
});
window.$gz._.forEach(
response.data,
function commitFetchedLTItemToStore(item) {
window.$gz.store.commit("addLocaleText", item);
}
);
resolve();
});
@@ -118,7 +121,7 @@ export default {
return v;
},
format() {
return store.state.locale;
return window.$gz.store.state.locale;
},
////////////////////////////////////////////////////////
// Take in a string that contains one or more