Skip to content

Commit

Permalink
Merge pull request #62 from IDEMSInternational/Bug-in-fix-arg-qr-code
Browse files Browse the repository at this point in the history
Investigating bug in QR code found during Mexico deployment
  • Loading branch information
edmoss345 authored Jan 30, 2024
2 parents 5457206 + 94144ad commit ea85a83
Show file tree
Hide file tree
Showing 5 changed files with 45,451 additions and 266 deletions.
2 changes: 1 addition & 1 deletion chatbot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ node index localize <input-rapidpro-flow-file> <translated-strings-file> <langua
Look for errors in the link between QR and Arguments that have been introduced during translation and apply an auto-fix.

```
node index fix_arg_qr_translation <rapidpro-json-file> <output-dir>
node index fix_arg_qr_translation <rapidpro-json-file> <output-dir> <file-output-name> <log-output-name>
```

### move\_quick\_replies
Expand Down
17 changes: 8 additions & 9 deletions chatbot/insert/fix_arg_qr_translation.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ const utility = require('./translation_functions.js');
const fs = require('fs');

// Code for running local tests on function - leave in place
//let filePath = "C:/Users/edmun/Google Drive - EEM Engineering Ltd/Translation Checking/SA 13.12.21/7 - PLH_with_afr_sot_tsn_xho_zul.json"
//let obj = JSON.parse(fs.readFileSync(filePath).toString());
//const [a, b] = fix_arg_qr_translation(obj);
// let filePath = "C:/Users/edmun/Code/idems_translation/chatbot/test/Other_Test_files/mexico_test.json"
// let obj = JSON.parse(fs.readFileSync(filePath).toString());
// const [a, b] = fix_arg_qr_translation(obj);

function fix_arg_qr_translation(object) {

Expand Down Expand Up @@ -65,7 +65,7 @@ function fix_arg_qr_translation(object) {

for (const action of node.actions) {
if (action.type == 'send_msg') {
if (action.quick_replies.length > 0) {
if (action.quick_replies.length > 0) {
TotalQRNodes++
//Before we start checking if there are problems with the translation we first check if there is an associated wait for response node with arguments
if(routers[node.exits[0].destination_uuid]){
Expand All @@ -79,8 +79,7 @@ function fix_arg_qr_translation(object) {
}
}
}
}

}
}
}

Expand Down Expand Up @@ -130,7 +129,7 @@ function fix_translated_arguments(flow, node, action, curr_loc, routers, debug_l

if(MissingTranslationCount>0){
NonTranslatedQR[lang]++
incompleteargumenttranslation[lang] = true
incompleteQRtranslation[lang] = true
}
}

Expand Down Expand Up @@ -172,8 +171,8 @@ function fix_translated_arguments(flow, node, action, curr_loc, routers, debug_l
let OriginalArguments = [...OtherArg[lang]]

// check if the EngQR are the same as the translatedQR, this means the quick replies have not been translated and therefore we shouldnt bother applying a fix
if(utility.arrayEquals(EngQR, OtherQR[lang])){
//debug_lang[lang] += '##### Quick replies not translated at all, therefore no automatic fix attempted\n'
if(utility.arrayEquals(EngQR, OtherQR[lang]) || OtherQR[lang].length == 0){
//debug_lang[lang] += '##### Quick replies not translated, therefore no automatic fix attempted\n'
break
}

Expand Down
2 changes: 1 addition & 1 deletion chatbot/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ea85a83

Please sign in to comment.