Skip to content

Commit 7c042ac

Browse files
feat(i18n): Add Bulgarian translation workflow using claude-code-action (#6)
* test(i18n): verify Anthropic API key works with claude-code-action Adding minimal workflow to test API key connectivity before building the full translation automation. * test(i18n): use workflow_dispatch to test API key with claude-code-action * fix(i18n): add id-token permission required by claude-code-action * feat(i18n): full Bulgarian translation workflow using claude-code-action Replaces the legacy npm CLI approach with the official anthropics/claude-code-action@v1. Claude reads both language files, identifies missing/changed keys, and updates main-bg.json directly.
1 parent 36ce5a1 commit 7c042ac

2 files changed

Lines changed: 107 additions & 0 deletions

File tree

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
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 }}

lang/main.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1684,5 +1684,8 @@
16841684
"heading": "Whiteboard"
16851685
},
16861686
"screenTitle": "Whiteboard"
1687+
},
1688+
"workflowTest": {
1689+
"apiKeyTest": "This is a test key to verify the API key works"
16871690
}
16881691
}

0 commit comments

Comments
 (0)