This commit is contained in:
@@ -116,8 +116,10 @@ export default {
|
|||||||
transData.data.forEach(function commitFetchedTranslationItemToStore(
|
transData.data.forEach(function commitFetchedTranslationItemToStore(
|
||||||
item
|
item
|
||||||
) {
|
) {
|
||||||
|
console.log("Committing new translation:", item);
|
||||||
window.$gz.store.commit("setTranslationText", item);
|
window.$gz.store.commit("setTranslationText", item);
|
||||||
});
|
});
|
||||||
|
console.log("Resolving fetch");
|
||||||
return resolve();
|
return resolve();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -290,49 +292,32 @@ export default {
|
|||||||
// Take in a string that contains one or more
|
// Take in a string that contains one or more
|
||||||
//translation keys that start with LT:
|
//translation keys that start with LT:
|
||||||
//translate each and replace and return the string translated
|
//translate each and replace and return the string translated
|
||||||
//
|
// (fetch and cache any missing strings)
|
||||||
translateString(s) {
|
async 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;
|
|
||||||
|
|
||||||
let ret = s;
|
let ret = s;
|
||||||
let found = s.match(/LT:[\w]*/gm);
|
let found = s.match(/LT:[\w]*/gm);
|
||||||
if (found == null) {
|
if (found == null) {
|
||||||
return ret;
|
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 => {
|
found.forEach(z => {
|
||||||
console.log("Geting value for key:", z);
|
|
||||||
let translated = this.get(z.replace("LT:", ""));
|
let translated = this.get(z.replace("LT:", ""));
|
||||||
console.log("Translated:", translated);
|
console.log("doreplace:", { z: z, translated: translated });
|
||||||
//replace all
|
//replace all
|
||||||
ret = ret.split(z).join(translated);
|
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;
|
return ret;
|
||||||
// const regex = /\bLT:[a-zA-Z]*\b/g;
|
|
||||||
// const found = stringtosearch.match(regex);
|
|
||||||
// found=array of strings
|
|
||||||
},
|
},
|
||||||
|
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ export default {
|
|||||||
this.languageName,
|
this.languageName,
|
||||||
this.hour12
|
this.hour12
|
||||||
),
|
),
|
||||||
status: window.$gz.translation.translateString(o.statusText),
|
status: await window.$gz.translation.translateString(o.statusText),
|
||||||
jobId:
|
jobId:
|
||||||
o.jobId == "00000000-0000-0000-0000-000000000000" ? "" : o.jobId
|
o.jobId == "00000000-0000-0000-0000-000000000000" ? "" : o.jobId
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user