name: Translation Lint on: pull_request: paths: - 'src/duckstation-qt/translations/*.ts' - 'src/duckstation-qt/translations/*.sh' - 'src/duckstation-qt/translations/*.bat' - 'scripts/translation/**' - '.github/workflows/translation-lint.yml' push: branches: - master - dev paths: - 'src/duckstation-qt/translations/*.ts' - 'src/duckstation-qt/translations/*.sh' - 'src/duckstation-qt/translations/*.bat' - 'scripts/translation/**' - '.github/workflows/translation-lint.yml' workflow_dispatch: permissions: contents: read jobs: translation-lint: runs-on: ubuntu-slim timeout-minutes: 120 steps: - uses: actions/checkout@v7 with: fetch-depth: 0 - name: Test Translation Tools run: python -m unittest discover -s scripts/translation/tests -v - name: Check Translation Catalogs shell: bash env: EVENT_NAME: ${{ github.event_name }} BASE_SHA: ${{ github.event.pull_request.base.sha }} HEAD_SHA: ${{ github.event.pull_request.head.sha }} BEFORE_SHA: ${{ github.event.before }} AFTER_SHA: ${{ github.sha }} run: | if [[ "$EVENT_NAME" == "pull_request" ]]; then mapfile -t files < <( git diff --name-only --diff-filter=ACMRT "$BASE_SHA...$HEAD_SHA" -- \ 'src/duckstation-qt/translations/*.ts' ) elif [[ "$EVENT_NAME" == "push" ]]; then mapfile -t files < <( git diff --name-only --diff-filter=ACMRT "$BEFORE_SHA..$AFTER_SHA" -- \ 'src/duckstation-qt/translations/*.ts' ) else files=() fi if (( ${#files[@]} == 0 )); then echo "No translation files to validate." exit 0 fi for file in "${files[@]}"; do python scripts/translation/validate_ts.py \ --reject-obsolete --reject-locations "$file" done