Skip to content

Commit 5a25476

Browse files
authored
feat(tools): add list-untranslated script to identify untranslated files (#1086)
1 parent 4238333 commit 5a25476

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"test": "pnpm run test:patch",
1414
"test:patch": "git apply -v --check --directory origin ./tools/adev-patches/*.patch",
1515
"update-origin": "tsx tools/update-origin.ts",
16+
"list-untranslated": "tsx tools/list-untranslated.ts",
1617
"translate": "tsx --env-file=.env tools/translator/main.ts"
1718
},
1819
"packageManager": "pnpm@10.15.0",

tools/list-untranslated.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env tsx
2+
3+
/**
4+
* @fileoverview Lists files in adev-ja that don't have corresponding .en.* backup files,
5+
* indicating they haven't been translated yet.
6+
*/
7+
8+
import { consola } from 'consola';
9+
import { extname, resolve } from 'node:path';
10+
import { exists, getEnFilePath, glob } from './lib/fsutils';
11+
import { adevJaDir } from './lib/workspace';
12+
13+
async function main() {
14+
const files = await glob(['**/*.{md,ts,html,json}', '!**/license.md'], {
15+
cwd: adevJaDir,
16+
});
17+
const untranslated = [];
18+
19+
for (const file of files) {
20+
const ext = extname(file);
21+
if (file.includes(`.en${ext}`)) continue;
22+
if (!(await exists(resolve(adevJaDir, getEnFilePath(file))))) {
23+
untranslated.push(file);
24+
}
25+
}
26+
27+
untranslated.length
28+
? consola.info(
29+
`Found ${untranslated.length} untranslated files:\n${untranslated
30+
.sort()
31+
.map((f) => ` ${f}`)
32+
.join('\n')}`
33+
)
34+
: consola.success('All files translated! 🎉');
35+
}
36+
37+
main().catch((error) => {
38+
consola.error(error);
39+
process.exit(1);
40+
});

0 commit comments

Comments
 (0)