From 122a1f4907f01170b7c71d54fa94144b4629256a Mon Sep 17 00:00:00 2001 From: Suguru Inatomi Date: Sat, 27 Sep 2025 18:05:25 +0900 Subject: [PATCH] feat(tools): add list-untranslated script to identify untranslated files --- package.json | 1 + tools/list-untranslated.ts | 40 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100755 tools/list-untranslated.ts diff --git a/package.json b/package.json index fa9be2bc5..45dee08fb 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "test": "pnpm run test:patch", "test:patch": "git apply -v --check --directory origin ./tools/adev-patches/*.patch", "update-origin": "tsx tools/update-origin.ts", + "list-untranslated": "tsx tools/list-untranslated.ts", "translate": "tsx --env-file=.env tools/translator/main.ts" }, "packageManager": "pnpm@10.15.0", diff --git a/tools/list-untranslated.ts b/tools/list-untranslated.ts new file mode 100755 index 000000000..853b1701f --- /dev/null +++ b/tools/list-untranslated.ts @@ -0,0 +1,40 @@ +#!/usr/bin/env tsx + +/** + * @fileoverview Lists files in adev-ja that don't have corresponding .en.* backup files, + * indicating they haven't been translated yet. + */ + +import { consola } from 'consola'; +import { extname, resolve } from 'node:path'; +import { exists, getEnFilePath, glob } from './lib/fsutils'; +import { adevJaDir } from './lib/workspace'; + +async function main() { + const files = await glob(['**/*.{md,ts,html,json}', '!**/license.md'], { + cwd: adevJaDir, + }); + const untranslated = []; + + for (const file of files) { + const ext = extname(file); + if (file.includes(`.en${ext}`)) continue; + if (!(await exists(resolve(adevJaDir, getEnFilePath(file))))) { + untranslated.push(file); + } + } + + untranslated.length + ? consola.info( + `Found ${untranslated.length} untranslated files:\n${untranslated + .sort() + .map((f) => ` ${f}`) + .join('\n')}` + ) + : consola.success('All files translated! 🎉'); +} + +main().catch((error) => { + consola.error(error); + process.exit(1); +});