This commit is contained in:
2020-12-10 15:56:36 +00:00
parent 0ae8266a8e
commit 19ee14ca85
2 changed files with 16 additions and 31 deletions

View File

@@ -116,8 +116,10 @@ export default {
transData.data.forEach(function commitFetchedTranslationItemToStore(
item
) {
console.log("Committing new translation:", item);
window.$gz.store.commit("setTranslationText", item);
});
console.log("Resolving fetch");
return resolve();
});
},
@@ -290,49 +292,32 @@ export default {
// Take in a string that contains one or more
//translation keys that start with LT:
//translate each and replace and return the string translated
//
translateString(s) {
console.log("#### START OF translateString:", s);
/*Error processing item 7: LT:Errors
LT:ErrorAPI2208 ,LT:Customer
*/
// let regex = new RegExp(/\bLT:[a-zA-Z]*\b/g, "m");
// let regex = /\bLT:[a-zA-Z]*\b/g;
// (fetch and cache any missing strings)
async translateString(s) {
let ret = s;
let found = s.match(/LT:[\w]*/gm);
if (found == null) {
return ret;
}
//clean up the keys for fetching
let keysToCache = found.map(z => z.replace("LT:", ""));
console.log("Caching:", keysToCache);
//cache / fetch any that are not already present
//(async () => {
await this.cacheTranslations(keysToCache);
// })();
console.log("done Caching");
//replace
found.forEach(z => {
console.log("Geting value for key:", z);
let translated = this.get(z.replace("LT:", ""));
console.log("Translated:", translated);
console.log("doreplace:", { z: z, translated: translated });
//replace all
ret = ret.split(z).join(translated);
});
// console.log("found", found);
// //-------------
// let ret = s;
// // let pattern = /\bLT:[a-zA-Z]*\b/g;
// let pattern = /LT:[\w]*/gm;
// let match;
// while ((match = pattern.exec(s)) != null) {
// console.log("Match: ", match);
// let foundMatch = match[0];
// let tKey = match[1];
// console.log("Geting value for key:", tKey);
// let newValue = this.get(tKey);
// ret = ret.replace(foundMatch, newValue);
// }
return ret;
// const regex = /\bLT:[a-zA-Z]*\b/g;
// const found = stringtosearch.match(regex);
// found=array of strings
},
////////////////////////////////////////////////////////

View File

@@ -104,7 +104,7 @@ export default {
this.languageName,
this.hour12
),
status: window.$gz.translation.translateString(o.statusText),
status: await window.$gz.translation.translateString(o.statusText),
jobId:
o.jobId == "00000000-0000-0000-0000-000000000000" ? "" : o.jobId
});