refactor: rename i18n utility scripts to `i18n:check` and `i18n:gen` across package scripts, workflows, tests, and documentation.

This commit is contained in:
yyh 2025-12-29 16:31:41 +08:00
parent 2c919efa69
commit 59a893afa3
No known key found for this signature in database
7 changed files with 16 additions and 16 deletions

View File

@ -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'

View File

@ -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')

View File

@ -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}`, `<tag>`) 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).

View File

@ -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 <name...> 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

View File

@ -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 <name...> 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(', ')}`)

View File

@ -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/**',

View File

@ -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",