Pular para o conteúdo principal

Integração CI/CD

Automatize as traduções no seu pipeline de build.

GitHub Actions: Sincronização no Push

Adicione a sincronização de tradução ao seu pipeline de build existente:

.github/workflows/deploy.yml
jobs:
build:
steps:
- uses: actions/checkout@v4
- run: npm ci
- name: Sync translations
env:
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
run: npx i18n-rosetta sync
- run: npm run build

GitHub Actions: Sincronização Agendada

Execute as traduções de forma agendada e faça o auto-commit:

.github/workflows/i18n-sync.yml
name: Sync translations
on:
schedule:
- cron: '0 6 * * *'
workflow_dispatch:

jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- name: Sync translations
env:
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
run: npx i18n-rosetta sync
- name: Commit updated translations
run: |
git config user.name "i18n-rosetta"
git config user.email "bot@example.com"
git add i18n/ content/ locales/ messages/
git diff --staged --quiet || git commit -m "chore: sync translations"
git push

Método Google Translate

Se você estiver usando o método integrado do Google Translate em vez do OpenRouter:

- name: Sync translations
env:
GOOGLE_TRANSLATE_API_KEY: ${{ secrets.GOOGLE_TRANSLATE_API_KEY }}
run: npx i18n-rosetta sync

Provedores de LLM Diretos

Se você estiver usando os métodos openai, anthropic ou gemini diretamente:

# OpenAI
- name: Sync translations
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: npx i18n-rosetta sync --method openai

# Anthropic
- name: Sync translations
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: npx i18n-rosetta sync --method anthropic

# Gemini (free tier available)
- name: Sync translations
env:
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
run: npx i18n-rosetta sync --method gemini

DeepL

- name: Sync translations
env:
DEEPL_API_KEY: ${{ secrets.DEEPL_API_KEY }}
run: npx i18n-rosetta sync --method deepl

API de Tradução Remota

Se você estiver usando um endpoint de tradução remota (por exemplo, um serviço de tradução hospedado):

- name: Sync translations
env:
ROSETTA_API_KEY: ${{ secrets.ROSETTA_API_KEY }}
run: npx i18n-rosetta sync

Pipeline de CI de Três Camadas

Para obter a máxima cobertura de i18n, valide seu pipeline com todas as três ferramentas:

jobs:
i18n:
steps:
- uses: actions/checkout@v4
- run: npm ci

# 1. Catch hardcoded strings before they ship
- run: npx i18n-rosetta lint

# 2. Translate missing keys
- run: npx i18n-rosetta sync
env:
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}

# 3. Fail if any locale is incomplete
- run: npx i18n-rosetta audit
CamadaComandoQuandoPropósito
LintlintPre-commitBloquear commits com strings hardcoded
SyncsyncPost-commit / CITraduzir chaves ausentes e alteradas
AuditauditEtapa de buildFalhar o deploy se alguma localidade estiver incompleta

Veja Também