From 772d76786836171a36bd3e233467f0bc7b792049 Mon Sep 17 00:00:00 2001 From: Ian Stride Date: Mon, 16 Aug 2021 12:31:35 +0100 Subject: [PATCH] Treat top-level directories as separate source code projects The 'app', 'chatbot' and 'common_tools' directories may use different technologies, which require different tools to manage, so it seems best not to treat them as part of a single project. --- README.md | 47 +++---------------- chatbot/README.md | 30 ++++++++++++ .../package-lock.json | 16 +------ package.json => chatbot/package.json | 9 ++-- {test => chatbot/test}/export-test.js | 2 +- common_tools/README.md | 29 ++++++++++++ common_tools/package-lock.json | 28 +++++++++++ common_tools/package.json | 19 ++++++++ 8 files changed, 119 insertions(+), 61 deletions(-) create mode 100644 chatbot/README.md rename package-lock.json => chatbot/package-lock.json (99%) rename package.json => chatbot/package.json (71%) rename {test => chatbot/test}/export-test.js (99%) create mode 100644 common_tools/README.md create mode 100644 common_tools/package-lock.json create mode 100644 common_tools/package.json diff --git a/README.md b/README.md index bf6de05..dcabe3b 100644 --- a/README.md +++ b/README.md @@ -20,46 +20,13 @@ For the app the possible types are: ??? ## Getting started -Install latest Long-Term Support (LTS) release of Node.js. +See READMEs for each project. -Install project dependencies. -``` -npm install -``` - -## Running the scripts - -### Common tools - -Identify messages that are mising a translation. -``` -node common_tools\index missing ".\test_files\current_translation_list.json" ".\test_files\translation_dictionary.json" ".\test_files\output" -``` - -??? -``` -node common_tools\index match ".\test_files\output\missing_bits_to_translate.json" ".\test_files\translation_dictionary.json" ".\test_files\output" -``` - -??? -``` -node common_tools\index add_restored ".\test_files\output\selected_best_matches.json" ".\test_files\translation_dictionary.json" ".\test_files\output" -``` - -### Chatbot +- [App][1] +- [Chatbot][2] +- [Common tools][3] -To extract English-language strings from RapidPro flows, for translation. -``` -node chatbot/index extract -``` -To merge translated strings back into original flow as a localization. -``` -node chatbot/index localize -``` - -## Running tests - -``` -npm test -``` +[1]: ./app/README_app.md +[2]: ./chatbot/README.md +[3]: ./common_tools/README.md diff --git a/chatbot/README.md b/chatbot/README.md new file mode 100644 index 0000000..f08af9a --- /dev/null +++ b/chatbot/README.md @@ -0,0 +1,30 @@ +# Chatbot translation tools + +## Getting started + +Install latest Long-Term Support (LTS) release of Node.js. + +Install project dependencies. +``` +npm install +``` + +## Running the scripts + +To extract English-language strings from RapidPro flows, for translation. +``` +node index extract +``` + +To merge translated strings back into original flow as a localization. +``` +node index localize +``` + +## Running tests + +``` +npm test +``` + + diff --git a/package-lock.json b/chatbot/package-lock.json similarity index 99% rename from package-lock.json rename to chatbot/package-lock.json index 3df9e82..1555ac3 100644 --- a/package-lock.json +++ b/chatbot/package-lock.json @@ -1,15 +1,13 @@ { - "name": "idems_translation", + "name": "idems_translation_chatbot", "version": "1.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { + "name": "idems_translation_chatbot", "version": "1.0.0", "license": "ISC", - "dependencies": { - "string-similarity": "^4.0.4" - }, "devDependencies": { "mocha": "^9.0.2" } @@ -799,11 +797,6 @@ "randombytes": "^2.1.0" } }, - "node_modules/string-similarity": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/string-similarity/-/string-similarity-4.0.4.tgz", - "integrity": "sha512-/q/8Q4Bl4ZKAPjj8WerIBJWALKkaPRfrvhfF8k/B23i4nzrlRj2/go1m90In7nG/3XDSbOo0+pu6RvCTM9RGMQ==" - }, "node_modules/string-width": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", @@ -1637,11 +1630,6 @@ "randombytes": "^2.1.0" } }, - "string-similarity": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/string-similarity/-/string-similarity-4.0.4.tgz", - "integrity": "sha512-/q/8Q4Bl4ZKAPjj8WerIBJWALKkaPRfrvhfF8k/B23i4nzrlRj2/go1m90In7nG/3XDSbOo0+pu6RvCTM9RGMQ==" - }, "string-width": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", diff --git a/package.json b/chatbot/package.json similarity index 71% rename from package.json rename to chatbot/package.json index e28cf09..e649152 100644 --- a/package.json +++ b/chatbot/package.json @@ -1,8 +1,8 @@ { - "name": "idems_translation", + "name": "idems_translation_chatbot", "version": "1.0.0", - "description": "translation tools", - "main": ".\\common_tools\\index.js", + "description": "Translation tools for chatbots", + "main": "index.js", "scripts": { "test": "mocha" }, @@ -16,9 +16,6 @@ "url": "https://github.com/fagiothree/idems_translation/issues" }, "homepage": "https://github.com/fagiothree/idems_translation#readme", - "dependencies": { - "string-similarity": "^4.0.4" - }, "devDependencies": { "mocha": "^9.0.2" } diff --git a/test/export-test.js b/chatbot/test/export-test.js similarity index 99% rename from test/export-test.js rename to chatbot/test/export-test.js index 94796e5..e2ae920 100644 --- a/test/export-test.js +++ b/chatbot/test/export-test.js @@ -1,5 +1,5 @@ const assert = require('assert'); -const extract = require('../chatbot/extract/extract.js'); +const extract = require('../extract/extract.js'); describe( diff --git a/common_tools/README.md b/common_tools/README.md new file mode 100644 index 0000000..810abe0 --- /dev/null +++ b/common_tools/README.md @@ -0,0 +1,29 @@ +# Common translation tools + +## Getting started + +Install latest Long-Term Support (LTS) release of Node.js. + +Install project dependencies. +``` +npm install +``` + +## Running the scripts + +### Common tools + +Identify messages that are mising a translation. +``` +node index missing ".\test_files\current_translation_list.json" ".\test_files\translation_dictionary.json" ".\test_files\output" +``` + +??? +``` +node index match ".\test_files\output\missing_bits_to_translate.json" ".\test_files\translation_dictionary.json" ".\test_files\output" +``` + +??? +``` +node index add_restored ".\test_files\output\selected_best_matches.json" ".\test_files\translation_dictionary.json" ".\test_files\output" +``` diff --git a/common_tools/package-lock.json b/common_tools/package-lock.json new file mode 100644 index 0000000..da9aa60 --- /dev/null +++ b/common_tools/package-lock.json @@ -0,0 +1,28 @@ +{ + "name": "idems_translation_common", + "version": "1.0.0", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "idems_translation_common", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "string-similarity": "^4.0.4" + } + }, + "node_modules/string-similarity": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/string-similarity/-/string-similarity-4.0.4.tgz", + "integrity": "sha512-/q/8Q4Bl4ZKAPjj8WerIBJWALKkaPRfrvhfF8k/B23i4nzrlRj2/go1m90In7nG/3XDSbOo0+pu6RvCTM9RGMQ==" + } + }, + "dependencies": { + "string-similarity": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/string-similarity/-/string-similarity-4.0.4.tgz", + "integrity": "sha512-/q/8Q4Bl4ZKAPjj8WerIBJWALKkaPRfrvhfF8k/B23i4nzrlRj2/go1m90In7nG/3XDSbOo0+pu6RvCTM9RGMQ==" + } + } +} diff --git a/common_tools/package.json b/common_tools/package.json new file mode 100644 index 0000000..be08ba5 --- /dev/null +++ b/common_tools/package.json @@ -0,0 +1,19 @@ +{ + "name": "idems_translation_common", + "version": "1.0.0", + "description": "Common translation tools", + "main": "index.js", + "repository": { + "type": "git", + "url": "git+https://github.com/fagiothree/idems_translation.git" + }, + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/fagiothree/idems_translation/issues" + }, + "homepage": "https://github.com/fagiothree/idems_translation#readme", + "dependencies": { + "string-similarity": "^4.0.4" + } +}