From 0ae8266a8ea5fa91d5753a6d48f964b86d6ac164 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Thu, 10 Dec 2020 15:17:50 +0000 Subject: [PATCH] --- ayanova/src/api/translation.js | 47 ++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/ayanova/src/api/translation.js b/ayanova/src/api/translation.js index 54e2bc69..a12e5557 100644 --- a/ayanova/src/api/translation.js +++ b/ayanova/src/api/translation.js @@ -293,21 +293,42 @@ export default { // 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 pattern = /\bLT:[a-zA-Z]*\b/g; - let match; - - This is fucked, maybe change it, not sure what the fuck it's doing actually it doesn't seem to be iterating each key - //seems to be missing shit, not right, missses if start of string, matches just LT: by itself for some reason...meh - - 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); + let found = s.match(/LT:[\w]*/gm); + if (found == null) { + return ret; } + + found.forEach(z => { + console.log("Geting value for key:", z); + let translated = this.get(z.replace("LT:", "")); + console.log("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);