Traduzioni Automatiche del Blog con Claude e GitHub Actions
Ogni post che scrivo viene tradotto automaticamente. Claude gestisce la traduzione, committa i risultati su main, e le versioni tradotte vengono deployate insieme all’originale.
Il Flusso
Il workflow di traduzione viene eseguito in GitHub Actions quando il contenuto in inglese viene mergiato su main:
on:
push:
branches: [main]
paths:
- 'content/**/*.en.md'
flowchart LR
B[Merge su main] --> C[Traduzioni generate]
C --> D[Committato su main]
D --> E[Deploy in produzione con tutte le lingue]
Il Prompt
Il workflow usa claude-code-action:
For each .en.md file that was added or modified:
1. Read the English content
2. Create translations for these languages: es, nl, de, it, fr, ja, zh, ru, hi
3. Save each translation as filename.{lang}.md (e.g., hello-world.es.md)
4. Preserve the frontmatter structure exactly, but translate the title
5. Translate the body content naturally
6. Keep code blocks, URLs, file paths, and technical terms unchanged
Un singolo prompt gestisce tutte e 9 le lingue. “Traduci naturalmente” produce un output più fluido di “traduci questo testo.” I blocchi di codice e i termini tecnici rimangono in inglese.
Gestione del Front Matter
I post di Hugo hanno front matter YAML. Alcuni campi devono essere tradotti (titolo), altri no (data, slug):
“Preserva la struttura del frontmatter esattamente, ma traduci il titolo”
Inglese:
---
title: "Hello World"
date: 2025-12-20
draft: false
---
Hindi:
---
title: "नमस्ते दुनिया"
date: 2025-12-20
draft: false
---
Il Commit
Il workflow imposta un’identità bot e limita ciò che Claude può fare:
- name: Setup git identity
run: |
git config --global user.email "claude[bot]@users.noreply.github.com"
git config --global user.name "claude[bot]"
- name: Translate with Claude
uses: anthropics/claude-code-action@v1
with:
claude_args: "--allowedTools 'Write,Bash(git:*)'"
prompt: |
...
Use `git add`, `git commit`, and `git push` to add the translations directly to main.
--allowedTools limita Claude a scrivere file e eseguire comandi git.
Qualità
Abbastanza buono per un blog personale. Le traduzioni di Claude sono fluide e catturano bene il significato. Un madrelingua noterebbe occasionali frasi goffe, ma è meglio di quello che potrei fare io.
Altri Usi
Lo stesso pattern funziona per la generazione di documentazione, riassunti di changelog, scrittura di messaggi di commit e note di rilascio:
- Rilevare cosa è cambiato
- Inviare contenuto a Claude con istruzioni
- Committare i risultati sul branch