Skip to content

翻訳コンパイル自動化

プラグインの translations/locale_XX.ts から .qm を生成する手順と、GitHub Actions によるリリース時コンパイルです。

ソーススクリプトはリポジトリの tools/i18n/ にあります。

プラグイン翻訳ツール(i18n)

MuseScore レガシー QML プラグイン向けに、translations/locale_XX.ts の更新と .qm へのコンパイルを自動化します。

スクリプト役割
compile-translations.pylupdate / lrelease を実行
extract-musescore-contexts.py本体 .ts からコンテキスト一覧を再生成
compile-translations.ps1 / .sh上記 Python の薄いラッパ

関連ドキュメント: 国際化開発ガイド本体翻訳コンテキスト一覧


前提

  • Python 3.9+
  • lupdatelrelease が PATH にあること
    • Windows: Qt Online Installer で Qt 6 を入れ、...\Qt\6.x.x\msvc...\bin を PATH へ
    • Ubuntu: sudo apt-get install -y qt6-l10n-tools
    • macOS: Qt インストール後に bin を PATH へ

ローカルでの使い方

プラグイン構成例:

myplugin/
  myplugin.qml
  translations/
    locale_ja.ts

リポジトリルート、またはプラグイン群の親ディレクトリで:

powershell
# Windows
python tools/i18n/compile-translations.py --root .
python tools/i18n/compile-translations.py --plugin .\myplugin --languages ja,de

# 抽出のみ / コンパイルのみ
python tools/i18n/compile-translations.py --lupdate-only --languages ja
python tools/i18n/compile-translations.py --lrelease-only
bash
# macOS / Linux
python3 tools/i18n/compile-translations.py --root .
./tools/i18n/compile-translations.sh --plugin ./myplugin --languages ja,de

translations/ があるディレクトリをプラグインルートとみなして走査します。.ts が無ければ locale_<lang>.ts のスケルトンを作成してから lupdate します。


GitHub Actions(リリース時に自動コンパイル)

テンプレートはリポジトリ内の .github/workflows/compile-plugin-translations.yml です(private のため Web 上の直リンクは置きません)。

動作概要:

  1. release 公開時(または手動 workflow_dispatch)に起動
  2. Ubuntu 上で qt6-l10n-tools を導入
  3. compile-translations.py --lrelease-only(または update+release)を実行
  4. 生成された **/translations/*.qm を Release 資産としてアップロード

プラグイン専用リポジトリにコピーする場合:

  1. tools/i18n/ と workflow をリポジトリへ置く
  2. ソース(.qml)と translations/*.ts を Git 管理する(.qm は Action で生成でも可)
  3. GitHub で Release を作成する → .qm が添付される

.qm をリポジトリにコミットし続けたい場合は、別ジョブで stefanzweifel/git-auto-commit-action 等を足すか、ローカルでコンパイルしてから push してください。リリース資産として配るだけならコミットは不要です。


本体コンテキスト一覧の更新

powershell
python tools/i18n/extract-musescore-contexts.py

share/locale/musescore_en.tsinstruments_en.ts を読み、docs/translation-contexts.md の一覧表を更新します。