Skip to content

Conversation

@lacolaco
Copy link
Collaborator

概要

翻訳ツール (pnpm run translate) にディレクトリ対応と並列翻訳機能を追加しました。

変更内容

機能追加

  1. Glob パターン対応

    • 単一ファイルと glob パターンの両方に対応
    • .en.md/.en.ts/.en.json ファイルを自動除外
  2. 並列処理制御

    • -c/--concurrency オプションで並列数を指定(デフォルト: 2)
    • p-limit パッケージを使用して並列実行を制御
  3. 翻訳済みファイル管理

    • デフォルトでは .en.md が存在するファイルをスキップ
    • --force オプションで翻訳済みファイルも再処理
  4. エラーハンドリング改善

    • 失敗したファイルを記録して処理継続
    • エラー詳細を一時ファイルに保存
    • 最終サマリーで成功/失敗件数を表示

使用例

# 単一ファイル(従来通り)
pnpm run translate -w adev-ja/src/content/guide/di.md

# ディレクトリ配下すべて(未翻訳のみ)
pnpm run translate -w "adev-ja/src/content/guide/*.md"

# 並列数5で再帰的処理
pnpm run translate -w -c 5 "adev-ja/src/content/**/*.md"

# 翻訳済み含めて再処理
pnpm run translate -w --force "adev-ja/src/content/guide/*.md"

技術的詳細

  • 並列化ライブラリ: p-limit@7.2.0 を新規追加
  • エラーログ: /tmp/translate-errors-{timestamp}.log に詳細を保存
  • 翻訳済み判定: .en.md ファイルの存在確認で判定

動作確認

  • ヘルプメッセージ表示: ✅
  • 引数バリデーション: ✅
  • Glob パターン処理: ✅
  • 翻訳済みフィルタリング: ✅
  • 並列数変更(-c/--concurrency): ✅
  • --force オプション: ✅
  • エラーハンドリング: ✅
  • 最終サマリー表示: ✅

Enhance the translation tool to support directory-based batch translation
with configurable concurrency control.

Changes:
- Add glob pattern support for file matching
- Add -c/--concurrency option to control parallel processing (default: 2)
- Add --force option to re-translate already translated files
- Implement p-limit for parallel execution control
- Improve error handling with temp file logging
- Skip translated files by default (.en.md existence check)
- Display comprehensive summary with success/failure counts

Usage examples:
  pnpm run translate -w "adev-ja/src/content/guide/*.md"
  pnpm run translate -w -c 5 "adev-ja/src/content/**/*.md"
  pnpm run translate -w --force "adev-ja/src/content/guide/*.md"
@lacolaco lacolaco merged commit b526de7 into angular:main Nov 21, 2025
4 checks passed
@lacolaco lacolaco deleted the feat/translator-batch-mode branch November 21, 2025 02:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant