Files
web-Iot/tmp_dbg.cjs
2026-08-14 09:02:52 +08:00

35 lines
1.1 KiB
JavaScript

const fs = require('fs');
const path = require('path');
const root = 'src';
const exts = ['.tsx', '.ts', '.jsx', '.js'];
const excludeDirs = ['locales', 'node_modules'];
function walk(dir) {
const out = [];
for (const e of fs.readdirSync(dir, { withFileTypes: true })) {
const full = path.join(dir, e.name);
if (e.isDirectory()) { if (!excludeDirs.includes(e.name)) out.push(...walk(full)); }
else if (exts.includes(path.extname(e.name))) out.push(full);
}
return out;
}
const refRegex = /(?:i18n\.t|[^a-zA-Z]t)\(\s*['"`]([a-zA-Z][a-zA-Z0-9_.]*?)['"`]/g;
const files = walk(root);
let count = 0;
const byFile = {};
for (const f of files) {
const content = fs.readFileSync(f, 'utf8');
let m;
const found = [];
while ((m = refRegex.exec(content))) { found.push(m[1]); }
if (found.length) { byFile[f] = found; count += found.length; }
}
console.log('Total raw t() matches:', count);
// show a few files with their matches
let shown = 0;
for (const f of Object.keys(byFile)) {
if (shown > 25) break;
console.log('\n' + f + ' (' + byFile[f].length + '):');
console.log(' ' + byFile[f].slice(0, 12).join(', '));
shown++;
}