From 59a893afa349e4c8b6041b7494726ff9d8e9e3e8 Mon Sep 17 00:00:00 2001 From: yyh Date: Mon, 29 Dec 2025 16:31:41 +0800 Subject: [PATCH] refactor: rename i18n utility scripts to `i18n:check` and `i18n:gen` across package scripts, workflows, tests, and documentation. --- .github/workflows/translate-i18n-base-on-english.yml | 2 +- web/__tests__/check-i18n.test.ts | 2 +- web/i18n-config/README.md | 6 +++--- web/i18n-config/auto-gen-i18n.js | 8 ++++---- web/i18n-config/check-i18n.js | 8 ++++---- web/knip.config.ts | 2 +- web/package.json | 4 ++-- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/translate-i18n-base-on-english.yml b/.github/workflows/translate-i18n-base-on-english.yml index 06227859dd..a51350f630 100644 --- a/.github/workflows/translate-i18n-base-on-english.yml +++ b/.github/workflows/translate-i18n-base-on-english.yml @@ -65,7 +65,7 @@ jobs: - name: Generate i18n translations if: env.FILES_CHANGED == 'true' working-directory: ./web - run: pnpm run auto-gen-i18n ${{ env.FILE_ARGS }} + run: pnpm run i18n:gen ${{ env.FILE_ARGS }} - name: Create Pull Request if: env.FILES_CHANGED == 'true' diff --git a/web/__tests__/check-i18n.test.ts b/web/__tests__/check-i18n.test.ts index a6f86d8107..9f573bda10 100644 --- a/web/__tests__/check-i18n.test.ts +++ b/web/__tests__/check-i18n.test.ts @@ -3,7 +3,7 @@ import path from 'node:path' import vm from 'node:vm' import { transpile } from 'typescript' -describe('check-i18n script functionality', () => { +describe('i18n:check script functionality', () => { const testDir = path.join(__dirname, '../i18n-test') const testEnDir = path.join(testDir, 'en-US') const testZhDir = path.join(testDir, 'zh-Hans') diff --git a/web/i18n-config/README.md b/web/i18n-config/README.md index b0a96986a4..a148f48202 100644 --- a/web/i18n-config/README.md +++ b/web/i18n-config/README.md @@ -159,10 +159,10 @@ We have a list of languages that we support in the `languages.ts` file. But some ## Utility scripts -- Auto-fill translations: `pnpm run auto-gen-i18n --file app common --lang zh-Hans ja-JP [--dry-run]` +- Auto-fill translations: `pnpm run i18n:gen --file app common --lang zh-Hans ja-JP [--dry-run]` - Use space-separated values; repeat `--file` / `--lang` as needed. Defaults to all en-US files and all supported locales except en-US. - Protects placeholders (`{{var}}`, `${var}`, ``) before translation and restores them after. -- Check missing/extra keys: `pnpm run check-i18n --file app billing --lang zh-Hans [--auto-remove]` +- Check missing/extra keys: `pnpm run i18n:check --file app billing --lang zh-Hans [--auto-remove]` - Use space-separated values; repeat `--file` / `--lang` as needed. Returns non-zero on missing/extra keys; `--auto-remove` deletes extra keys automatically. -Workflows: `.github/workflows/translate-i18n-base-on-english.yml` auto-runs the translation generator on `web/i18n/en-US/*.json` changes to main. `check-i18n` is a manual script (not run in CI). +Workflows: `.github/workflows/translate-i18n-base-on-english.yml` auto-runs the translation generator on `web/i18n/en-US/*.json` changes to main. `i18n:check` is a manual script (not run in CI). diff --git a/web/i18n-config/auto-gen-i18n.js b/web/i18n-config/auto-gen-i18n.js index f84a2388af..4eff7b07ad 100644 --- a/web/i18n-config/auto-gen-i18n.js +++ b/web/i18n-config/auto-gen-i18n.js @@ -103,7 +103,7 @@ function parseArgs(argv) { } function printHelp() { - console.log(`Usage: pnpm run auto-gen-i18n [options] + console.log(`Usage: pnpm run i18n:gen [options] Options: --file Process only specific files; provide space-separated names and repeat --file if needed @@ -112,8 +112,8 @@ Options: -h, --help Show help Examples: - pnpm run auto-gen-i18n --file app common --lang zh-Hans ja-JP - pnpm run auto-gen-i18n --dry-run + pnpm run i18n:gen --file app common --lang zh-Hans ja-JP + pnpm run i18n:gen --dry-run `) } @@ -259,7 +259,7 @@ async function main() { return } - console.log('🚀 Starting auto-gen-i18n script...') + console.log('🚀 Starting i18n:gen script...') console.log(`📋 Mode: ${isDryRun ? 'DRY RUN (no files will be modified)' : 'LIVE MODE'}`) const filesInEn = fs diff --git a/web/i18n-config/check-i18n.js b/web/i18n-config/check-i18n.js index 5b6efec385..4ad9eb6513 100644 --- a/web/i18n-config/check-i18n.js +++ b/web/i18n-config/check-i18n.js @@ -90,7 +90,7 @@ function parseArgs(argv) { } function printHelp() { - console.log(`Usage: pnpm run check-i18n [options] + console.log(`Usage: pnpm run i18n:check [options] Options: --file Check only specific files; provide space-separated names and repeat --file if needed @@ -99,8 +99,8 @@ Options: -h, --help Show help Examples: - pnpm run check-i18n --file app billing --lang zh-Hans ja-JP - pnpm run check-i18n --auto-remove + pnpm run i18n:check --file app billing --lang zh-Hans ja-JP + pnpm run i18n:check --auto-remove `) } @@ -285,7 +285,7 @@ async function main() { return hasDiff } - console.log('🚀 Starting check-i18n script...') + console.log('🚀 Starting i18n:check script...') if (targetFiles.length) console.log(`📁 Checking files: ${targetFiles.join(', ')}`) diff --git a/web/knip.config.ts b/web/knip.config.ts index 8598d94e2d..975a85b997 100644 --- a/web/knip.config.ts +++ b/web/knip.config.ts @@ -168,7 +168,7 @@ const config: KnipConfig = { // ======================================================================== // 🔒 Utility scripts (not part of application runtime) // ======================================================================== - // These scripts are run manually (e.g., pnpm gen-icons, pnpm check-i18n) + // These scripts are run manually (e.g., pnpm gen-icons, pnpm i18n:check) // and are not imported by the application code. 'scripts/**', 'bin/**', diff --git a/web/package.json b/web/package.json index 2e03f04a62..3d5591c57c 100644 --- a/web/package.json +++ b/web/package.json @@ -33,8 +33,8 @@ "prepare": "cd ../ && node -e \"if (process.env.NODE_ENV !== 'production'){process.exit(1)} \" || husky ./web/.husky", "gen-icons": "node ./app/components/base/icons/script.mjs", "uglify-embed": "node ./bin/uglify-embed", - "check-i18n": "tsx ./i18n-config/check-i18n.js", - "auto-gen-i18n": "tsx ./i18n-config/auto-gen-i18n.js", + "i18n:check": "tsx ./i18n-config/check-i18n.js", + "i18n:gen": "tsx ./i18n-config/auto-gen-i18n.js", "test": "vitest run", "test:coverage": "vitest run --coverage", "test:watch": "vitest --watch",