Skip to content

Commit 77bd782

Browse files
author
hongarc
committed
feat: show unused key
1 parent 8eaa9f2 commit 77bd782

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/js/intl/checkStrings.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,28 @@ var { strings } = require('../intl/strings');
66

77
var easyRegex = /intl\.str\(\s*'([a-zA-Z\-]+)'/g;
88

9-
var goodKeys = 0;
9+
var allKetSet = new Set(Object.keys(strings));
10+
allKetSet.delete('error-untranslated'); // used in ./index.js
11+
12+
var goodKeySet = new Set();
1013
var validateKey = function(key) {
1114
if (!strings[key]) {
1215
console.log('NO KEY for: "', key, '"');
1316
} else {
14-
goodKeys++;
17+
goodKeySet.add(key);
18+
allKetSet.delete(key);
1519
}
1620
};
1721

1822
if (!util.isBrowser()) {
19-
util.readDirDeep(join(__dirname, '../..')).forEach(function(path) {
23+
util.readDirDeep(join(__dirname, '../../')).forEach(function(path) {
2024
var content = readFileSync(path);
2125
var match;
2226
while (match = easyRegex.exec(content)) {
23-
console.log(match[1])
2427
validateKey(match[1]);
2528
}
2629
});
27-
console.log(goodKeys + ' good keys found!');
30+
console.log(goodKeySet.size, ' good keys found!');
31+
console.log(allKetSet.size, ' keys did not use!');
32+
console.log(allKetSet);
2833
}

src/js/util/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,4 @@ exports.readDirDeep = function(dir) {
7171
}
7272
});
7373
return paths;
74-
}
74+
};

0 commit comments

Comments
 (0)