Skip to content

Commit

Permalink
misc tweaks to built-in tools
Browse files Browse the repository at this point in the history
  • Loading branch information
gfwilliams committed Jul 7, 2023
1 parent 3094dca commit 456d2c7
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 14 deletions.
17 changes: 17 additions & 0 deletions bin/language_scan.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@
outputs a list of strings that have been found.
See https://github.com/espruino/BangleApps/issues/1311
Needs old 'translate':
npm install translate@1.4.1
For actual translation you need to sign up for a free Deepl API at https://www.deepl.com/
```
# show status
bin/language_scan.js -r
# add missing keys for all languages (in english)
bin/language_scan.js -r
# for translation
bin/language_scan.js --deepl YOUR_API_KEY --turl https://api-free.deepl.com
*/

var childProcess = require('child_process');
Expand Down
40 changes: 26 additions & 14 deletions bin/lib/apploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,32 @@ exports.init = function(options) {
DEVICEID = options.DEVICEID;
device.id = options.DEVICEID;
}
// Load app metadata
var dirs = require("fs").readdirSync(APPSDIR, {withFileTypes: true});
dirs.forEach(dir => {
var appsFile;
if (dir.name.startsWith("_example") || !dir.isDirectory())
return;
try {
appsFile = require("fs").readFileSync(APPSDIR+dir.name+"/metadata.json").toString();
} catch (e) {
ERROR(dir.name+"/metadata.json does not exist");
return;
}
apps.push(JSON.parse(appsFile));
});
// Try loading from apps.json
apps.length=0;
try {
var appsStr = require("fs").readFileSync(BASE_DIR+"/apps.json");
var appList = JSON.parse(appsStr);
appList.forEach(a => apps.push(a));
} catch (e) {
console.log("Couldn't load apps.json", e.toString());
}
// Load app metadata from each app
if (!apps.length) {
console.log("Loading apps/.../metadata.json");
var dirs = require("fs").readdirSync(APPSDIR, {withFileTypes: true});
dirs.forEach(dir => {
var appsFile;
if (dir.name.startsWith("_example") || !dir.isDirectory())
return;
try {
appsFile = require("fs").readFileSync(APPSDIR+dir.name+"/metadata.json").toString();
} catch (e) {
console.error(dir.name+"/metadata.json does not exist");
return;
}
apps.push(JSON.parse(appsFile));
});
}
};

exports.AppInfo = AppInfo;
Expand Down

0 comments on commit 456d2c7

Please sign in to comment.