Files
TFG/.github/workflows/crowdin.yml
dependabot[bot] 7663c453b6 Bump the dependencies group with 3 updates (#3443)
Bumps the dependencies group with 3 updates: [actions/download-artifact](https://github.com/actions/download-artifact), [softprops/action-gh-release](https://github.com/softprops/action-gh-release) and [crowdin/github-action](https://github.com/crowdin/github-action).


Updates `actions/download-artifact` from 8.0.0 to 8.0.1
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v8.0.0...v8.0.1)

Updates `softprops/action-gh-release` from 2.5.0 to 2.6.1
- [Release notes](https://github.com/softprops/action-gh-release/releases)
- [Changelog](https://github.com/softprops/action-gh-release/blob/master/CHANGELOG.md)
- [Commits](https://github.com/softprops/action-gh-release/compare/v2.5.0...v2.6.1)

Updates `crowdin/github-action` from 2.15.0 to 2.15.2
- [Release notes](https://github.com/crowdin/github-action/releases)
- [Commits](https://github.com/crowdin/github-action/compare/v2.15.0...v2.15.2)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: 8.0.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: dependencies
- dependency-name: softprops/action-gh-release
  dependency-version: 2.6.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: dependencies
- dependency-name: crowdin/github-action
  dependency-version: 2.15.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-16 23:06:09 +00:00

233 lines
10 KiB
YAML

name: "Crowdin Translations"
run-name: "[🌐]: Crowdin Translations #${{ github.run_number }}"
on:
push:
branches: [dev]
paths:
- 'kubejs/assets/**/lang/en_us.json'
- 'kubejs/assets/**/patchouli_books/**/en_us/**/*.json'
workflow_dispatch:
inputs:
operation:
description: 'Operation type'
required: true
default: 'both'
type: choice
options:
- upload
- download
- both
- status
skip_pr:
description: 'Skip pull request creation'
required: false
default: false
type: boolean
export_approved_only:
description: 'Export only approved translations'
required: false
default: true
type: boolean
dry_run:
description: 'Dry run mode (no actual changes)'
required: false
default: false
type: boolean
download_language:
description: 'Download language (leave empty for all)'
required: false
default: ''
type: choice
options:
- ''
- 'de-DE'
- 'es-ES'
- 'fr-FR'
- 'jp-JP'
- 'pt-BR'
- 'ru-RU'
- 'uk-UA'
- 'zh-CN'
- 'zh-TW'
schedule:
# Run daily at 3 AM UTC
- cron: '0 3 * * *'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
pull-requests: write
jobs:
sync:
runs-on: ubuntu-latest
if: github.event.inputs.operation != 'status' || github.event.inputs.operation == ''
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Validate source files
run: |
echo " Validating source language files..."
# Check for required English source files
find kubejs/assets -name "en_us.json" -type f | while read file; do
echo " Found source file: $file"
# Basic JSON validation
if ! jq empty "$file" 2>/dev/null; then
echo " Invalid JSON in $file"
exit 1
fi
done
echo " All source files are valid JSON"
- name: Cache Crowdin source files
uses: actions/cache@v5
with:
path: ~/.crowdin/cache.json
key: ${{ runner.os }}-crowdin-cache-${{ github.ref_name }}-${{ hashFiles('**/crowdin.yml') }}
restore-keys: |
${{ runner.os }}-crowdin-cache-${{ github.ref_name }}-
- name: Set localization branch name
id: set_branch
run: |
if [ -z "${{ github.event.inputs.download_language }}" ]; then
echo "branch_name=translations/all" >> $GITHUB_OUTPUT
echo "pr_title_suffix=for ALL languages" >> $GITHUB_OUTPUT
else
lang=$(echo "${{ github.event.inputs.download_language }}" | tr '[:upper:]' '[:lower:]' | tr '-' '_')
echo "branch_name=translations/$lang" >> $GITHUB_OUTPUT
echo "pr_title_suffix=for ${{ github.event.inputs.download_language }} language" >> $GITHUB_OUTPUT
fi
- name: Create Pull Request
uses: crowdin/github-action@v2.15.2
with:
upload_sources: ${{ github.event.inputs.operation == 'upload' || github.event.inputs.operation == 'both' || github.event_name == 'schedule' }}
upload_translations: false
import_eq_suggestions: true
skip_untranslated_files: true
download_translations: ${{ github.event.inputs.operation == 'download' || github.event.inputs.operation == 'both' || github.event_name == 'schedule' }}
download_language: ${{ github.event.inputs.download_language }}
config: crowdin.yml
localization_branch_name: ${{ steps.set_branch.outputs.branch_name }}
create_pull_request: ${{ (github.event.inputs.skip_pr != 'true' || github.event.inputs.skip_pr == '') && ((github.event.inputs.operation == 'download' || github.event.inputs.operation == 'both') || github.event_name == 'schedule') }}
export_only_approved: ${{ github.event.inputs.export_approved_only || github.event_name == 'schedule' }}
commit_message: "[translation] New translations"
dryrun_action: ${{ github.event.inputs.dry_run == 'true' || false }}
pull_request_base_branch_name: 'dev'
pull_request_team_reviewers: 'modern-team'
pull_request_title: "[🌐]: New Crowdin translations ${{ steps.set_branch.outputs.pr_title_suffix }}"
pull_request_labels: "Pull request: Translation"
pull_request_body: |
## 🌐 New translations from Crowdin ${{ steps.set_branch.outputs.pr_title_suffix }}
### 📋 Summary
- **Trigger**: ${{ github.event_name }}
- **Operation**: ${{ github.event.inputs.operation || 'auto-sync' }}
- **Language**: ${{ github.event.inputs.download_language || 'All languages' }}
- **Approved only**: ${{ github.event.inputs.export_approved_only || 'true' }}
### 🔄 Changes
- Updated JSON translation files ${{ steps.set_branch.outputs.pr_title_suffix }}
- Patchouli book translations
- Language-specific improvements
### 🧪 Testing
Please test the translations in-game:
1. Switch to different languages
2. Check mod descriptions and tooltips
3. Verify Patchouli guide content
---
*Automated by [Crowdin GitHub Action](https://github.com/crowdin/github-action)*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_TOKEN }}
CROWDIN_ID: ${{ vars.CROWDIN_ID }}
# Status check job
status:
runs-on: ubuntu-latest
if: github.event.inputs.operation == 'status' || github.event.inputs.operation == ''
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Get Project Info
id: project-info
run: |
# Get project name from Crowdin API
PROJECT_INFO=$(curl -s -H "Authorization: Bearer ${{ secrets.CROWDIN_TOKEN }}" "https://api.crowdin.com/api/v2/projects/${{ vars.CROWDIN_ID }}")
PROJECT_NAME=$(echo "$PROJECT_INFO" | jq -r '.data.name')
echo "project-name=$PROJECT_NAME" >> $GITHUB_OUTPUT
echo "Project name: $PROJECT_NAME"
- name: Crowdin Translations Progress
uses: crowdin/github-action@v2.15.2
with:
command: 'status translation'
config: crowdin.yml
env:
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_TOKEN }}
CROWDIN_ID: ${{ vars.CROWDIN_ID }}
- name: Generate Status Report
run: |
echo "## 🌐 Crowdin Translation Status Report" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Project ID**: ${{ vars.CROWDIN_ID }}" >> $GITHUB_STEP_SUMMARY
echo "**Project Name**: ${{ steps.project-info.outputs.project-name }}" >> $GITHUB_STEP_SUMMARY
echo "**Language Filter**: ${{ github.event.inputs.download_language || 'All languages' }}" >> $GITHUB_STEP_SUMMARY
echo "**Generated**: $(date -u)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
# Get detailed language statistics using Crowdin CLI
echo "### 📊 Language Statistics" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ -n "${{ github.event.inputs.download_language }}" ]; then
echo "🔍 **Selected Language**: ${{ github.event.inputs.download_language }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
# Get status for specific language
LANG_STATUS=$(crowdin status translation --language ${{ github.event.inputs.download_language }} --format json 2>/dev/null | jq -r '.languages[] | select(.code == "${{ github.event.inputs.download_language }}") | "\(.code): \(.progress.translated)% translated, \(.progress.approved)% approved"')
if [ -n "$LANG_STATUS" ]; then
echo "- **Progress**: $LANG_STATUS" >> $GITHUB_STEP_SUMMARY
else
echo "- **Status**: Language not found in project" >> $GITHUB_STEP_SUMMARY
fi
else
echo "🌍 **All Languages Overview**" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
# Get overall project statistics
crowdin status translation --format json 2>/dev/null | jq -r '.languages[] | "\(.code): \(.progress.translated)% translated, \(.progress.approved)% approved"' | while read line; do
echo "$line" >> $GITHUB_STEP_SUMMARY
done
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "### 📈 Overall Project Progress" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
# Get overall statistics
OVERALL_STATS=$(crowdin status translation --format json 2>/dev/null | jq -r '"Overall: \(.progress.translated)% translated, \(.progress.approved)% approved, \(.progress.words.total) total words"')
if [ -n "$OVERALL_STATS" ]; then
echo "$OVERALL_STATS" >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "### 📋 Quick Actions" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- 🔗 [Crowdin Dashboard](https://crowdin.com/project/${{ steps.project-info.outputs.project-name }})" >> $GITHUB_STEP_SUMMARY
echo "- 📊 [Translation Management](https://crowdin.com/project/${{ steps.project-info.outputs.project-name }}/reports)" >> $GITHUB_STEP_SUMMARY
echo "- 🌐 [Language Settings](https://crowdin.com/project/${{ steps.project-info.outputs.project-name }}/settings#languages)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "📊 Use detailed statistics above to review translation progress." >> $GITHUB_STEP_SUMMARY