|
| 1 | +name: Auto-translate Bulgarian |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +permissions: |
| 7 | + contents: write |
| 8 | + pull-requests: write |
| 9 | + id-token: write |
| 10 | + |
| 11 | +jobs: |
| 12 | + translate: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + |
| 15 | + steps: |
| 16 | + - name: Checkout repository |
| 17 | + uses: actions/checkout@v4 |
| 18 | + with: |
| 19 | + fetch-depth: 2 |
| 20 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 21 | + |
| 22 | + - name: Translate Bulgarian updates |
| 23 | + uses: anthropics/claude-code-action@v1 |
| 24 | + with: |
| 25 | + anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} |
| 26 | + prompt: | |
| 27 | + You are a professional translator specializing in Bulgarian translations for software interfaces. |
| 28 | +
|
| 29 | + TASK: Update the Bulgarian translation file based on changes to the English translation file. |
| 30 | +
|
| 31 | + STEPS: |
| 32 | + 1. Read the file lang/main.json (English translations). |
| 33 | + 2. Read the file lang/main-bg.json (Bulgarian translations). |
| 34 | + 3. Compare the two files and identify keys that are in main.json but missing or different in main-bg.json. |
| 35 | + 4. Translate those keys professionally to Bulgarian. |
| 36 | + 5. Update lang/main-bg.json with the new translations, maintaining alphabetical key order. |
| 37 | +
|
| 38 | + TRANSLATION GUIDELINES: |
| 39 | + - Do not modify existing Bulgarian translations. Only add new keys or update keys whose English source has changed. |
| 40 | + - Think carefully and translate well. This is a very important task so put all the effort and knowledge you have to come up with the best translations. |
| 41 | + - Use professional, natural Bulgarian language. |
| 42 | + - Be consistent with the existing Bulgarian translations in lang/main-bg.json (terminology, formal/informal style, etc.). For example, if a specific word is used to translate "closed captions", continue using that same word for new translations as well. Maintain consistency in formal vs informal language, and anything else you can think of. |
| 43 | + - Mixed Bulgarian and English is unacceptable. Everything must be translated to proper Bulgarian. |
| 44 | + - Exception: Established technical terms that are widely used in English (like 'WebAssembly', 'URL', 'API') can remain in English if they don't have good Bulgarian translations and are commonly used by Bulgarian speakers. |
| 45 | + - Example: 'phone number' MUST be translated to Bulgarian, but 'WebAssembly' can stay in English. |
| 46 | + - Preserve any placeholders like {{variable}} or {name} exactly as they appear in the English version. |
| 47 | + - Maintain formal/informal consistency with existing translations. |
| 48 | + - The keys must be alphabetically ordered in the output file. |
| 49 | + - Use 4-space indentation for the JSON file. |
| 50 | +
|
| 51 | + Please read both files, identify what needs to be translated, and update lang/main-bg.json accordingly. |
| 52 | +
|
| 53 | + - name: Check for translation changes |
| 54 | + id: check_changes |
| 55 | + run: | |
| 56 | + if git diff --quiet lang/main-bg.json; then |
| 57 | + echo "has_changes=false" >> $GITHUB_OUTPUT |
| 58 | + else |
| 59 | + echo "has_changes=true" >> $GITHUB_OUTPUT |
| 60 | + fi |
| 61 | +
|
| 62 | + - name: Create Pull Request |
| 63 | + if: steps.check_changes.outputs.has_changes == 'true' |
| 64 | + run: | |
| 65 | + BRANCH_NAME="auto-translate-bulgarian-$(date +%Y%m%d-%H%M%S)" |
| 66 | +
|
| 67 | + git config user.name "GitHub Actions Bot" |
| 68 | + git config user.email "actions@github.com" |
| 69 | +
|
| 70 | + git checkout -b "$BRANCH_NAME" |
| 71 | + git add lang/main-bg.json |
| 72 | +
|
| 73 | + ADDED=$(git diff --cached lang/main-bg.json | grep -c '^+[^+]' || echo "0") |
| 74 | + REMOVED=$(git diff --cached lang/main-bg.json | grep -c '^-[^-]' || echo "0") |
| 75 | +
|
| 76 | + git commit -m "$(cat <<EOF |
| 77 | + feat(i18n): auto-update Bulgarian translations |
| 78 | +
|
| 79 | + Automated Bulgarian translation update based on changes to main.json. |
| 80 | + - Added/Updated: $ADDED line(s) |
| 81 | + - Removed: $REMOVED line(s) |
| 82 | + EOF |
| 83 | + )" |
| 84 | +
|
| 85 | + git push origin "$BRANCH_NAME" |
| 86 | +
|
| 87 | + gh pr create \ |
| 88 | + --title "feat(i18n): Auto-update Bulgarian translations" \ |
| 89 | + --body "$(cat <<'EOF' |
| 90 | + ## Summary |
| 91 | + - Automated Bulgarian translation update based on changes to main.json |
| 92 | + - Translations generated using Claude AI for consistency and quality |
| 93 | +
|
| 94 | + ## Test plan |
| 95 | + - [ ] Review translation quality and accuracy |
| 96 | + - [ ] Verify proper JSON formatting and indentation |
| 97 | + - [ ] Check that all new/modified keys from main.json are translated |
| 98 | + - [ ] Ensure consistency with existing Bulgarian translations |
| 99 | + EOF |
| 100 | + )" \ |
| 101 | + --base master \ |
| 102 | + --head "$BRANCH_NAME" |
| 103 | + env: |
| 104 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments