Updated PT_BR localization #5
Workflow file for this run
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # Do not edit this file directly | |
| # This file is synced by https://github.com/ChaoticTrials/ModMeta | |
| name: Check Localization Files | |
| on: | |
| pull_request_target: | |
| types: [ opened, synchronize, reopened ] | |
| paths: | |
| - 'src/main/resources/assets/**/lang/*.json' | |
| permissions: | |
| pull-requests: write | |
| contents: read | |
| jobs: | |
| check-localization: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.pull_request.head.ref }} | |
| repository: ${{ github.event.pull_request.head.repo.full_name }} | |
| fetch-depth: 0 | |
| - name: Debug PR context | |
| run: | | |
| echo "Pull request number: ${{ github.event.pull_request.number }}" | |
| echo "Repository full name: ${{ github.repository }}" | |
| echo "Event path: $GITHUB_EVENT_PATH" | |
| - name: Check localization files | |
| run: | | |
| PR_NUMBER="${{ github.event.pull_request.number }}" | |
| REPO_FULL_NAME="${{ github.repository }}" | |
| # Ensure GitHub CLI is authenticated and correctly identifies the PR context | |
| echo "Processing PR #$PR_NUMBER for repository $REPO_FULL_NAME" | |
| # Get the list of added or modified localization files | |
| FILES=$(gh pr diff "$PR_NUMBER" --repo "$REPO_FULL_NAME" --name-only | grep -E 'src/main/resources/assets/.*/lang/.*\.json' || true) | |
| if [[ -z "$FILES" ]]; then | |
| echo "No localization files have been modified." | |
| exit 0 | |
| fi | |
| # Initialize an array to store the missing keys | |
| MISSING_KEYS=() | |
| # Iterate over each file | |
| for FILE in $FILES; do | |
| # Check if the file is not the default English translation | |
| if [[ $FILE != *"en_us.json" ]]; then | |
| # Get the modid and language key from the file path | |
| MODID=$(echo $FILE | cut -d'/' -f5) | |
| LANGUAGE_KEY=$(echo $FILE | cut -d'/' -f7 | cut -d'.' -f1) | |
| # Check if all keys from the default English translation are included in this file | |
| KEYS=$(jq -n --slurpfile en src/main/resources/assets/$MODID/lang/en_us.json --slurpfile current $FILE '($en[0] | keys) - ($current[0] | keys)' ) | |
| if [[ $KEYS != "[]" ]]; then | |
| MISSING_KEYS+=("$LANGUAGE_KEY: $KEYS") | |
| fi | |
| fi | |
| done | |
| # Post a comment on the pull request with the missing keys or a success message | |
| if [[ ${#MISSING_KEYS[@]} -gt 0 ]]; then | |
| echo "# 🚨 Missing translation keys 🚨" > review.md | |
| for MISSING_KEY in "${MISSING_KEYS[@]}"; do | |
| LANGUAGE=$(echo $MISSING_KEY | cut -d':' -f1) | |
| KEYS=$(echo $MISSING_KEY | cut -d':' -f2 | jq -r '.[]') | |
| echo "## **$LANGUAGE**" >> review.md | |
| for KEY in $KEYS; do | |
| echo "- $KEY" >> review.md | |
| done | |
| echo "" >> review.md | |
| done | |
| # Request changes on the pull request | |
| gh pr review "$PR_NUMBER" --repo "$REPO_FULL_NAME" --request-changes --body-file review.md | |
| else | |
| echo "## ✅ All localization files have been checked and are complete! ✅" > review.md | |
| echo "Waiting for approval by @MelanX" >> review.md | |
| # Approve the pull request | |
| gh pr review "$PR_NUMBER" --repo "$REPO_FULL_NAME" --comment --body-file review.md | |
| fi | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |