|
| 1 | +name: Translate on main |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + pull-requests: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + translate: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - name: Checkout |
| 17 | + uses: actions/checkout@v4 |
| 18 | + |
| 19 | + - name: Setup Node |
| 20 | + uses: actions/setup-node@v4 |
| 21 | + with: |
| 22 | + node-version: 20 |
| 23 | + cache: npm |
| 24 | + |
| 25 | + - name: Install dependencies |
| 26 | + run: npm ci |
| 27 | + |
| 28 | + - name: Inject Lingo engine id into i18n config |
| 29 | + env: |
| 30 | + LINGO_ENGINE_ID: ${{ secrets.LINGO_ENGINE_ID }} |
| 31 | + run: | |
| 32 | + if [ -z "${LINGO_ENGINE_ID}" ]; then |
| 33 | + echo "LINGO_ENGINE_ID secret is required." |
| 34 | + exit 1 |
| 35 | + fi |
| 36 | + node -e 'const fs=require("fs");const p="i18n.json";const j=JSON.parse(fs.readFileSync(p,"utf8"));j.engineId=process.env.LINGO_ENGINE_ID;fs.writeFileSync(p,JSON.stringify(j,null,2)+"\n");' |
| 37 | +
|
| 38 | + - name: Sync API and webhook titles from OpenAPI |
| 39 | + run: node scripts/sync-openapi-titles.mjs |
| 40 | + |
| 41 | + - name: Run Lingo translation |
| 42 | + env: |
| 43 | + LINGO_API_KEY: ${{ secrets.LINGO_API_KEY }} |
| 44 | + run: | |
| 45 | + locales=$(node -e 'const fs=require("fs");const j=JSON.parse(fs.readFileSync("i18n.json","utf8"));console.log((j.locale?.targets||[]).join(" "));') |
| 46 | + if [ -z "$locales" ]; then |
| 47 | + echo "No target locales configured in i18n.json locale.targets" |
| 48 | + exit 1 |
| 49 | + fi |
| 50 | + for locale in $locales; do |
| 51 | + echo "Running Lingo translation for $locale" |
| 52 | + npx lingo.dev@latest run --target-locale "$locale" |
| 53 | + done |
| 54 | +
|
| 55 | + - name: Translate docs.json language-specific navigation |
| 56 | + env: |
| 57 | + LINGO_ENGINE_ID: ${{ secrets.LINGO_ENGINE_ID }} |
| 58 | + LINGO_API_KEY: ${{ secrets.LINGO_API_KEY }} |
| 59 | + run: | |
| 60 | + locales=$(node -e 'const fs=require("fs");const j=JSON.parse(fs.readFileSync("i18n.json","utf8"));console.log((j.locale?.targets||[]).join(" "));') |
| 61 | + for locale in $locales; do |
| 62 | + echo "Translating docs.json labels for $locale" |
| 63 | + node scripts/translate-docs-json.mjs --target "$locale" |
| 64 | + echo "Localizing internal links for $locale" |
| 65 | + node scripts/localize-internal-links.mjs --target "$locale" |
| 66 | + echo "Localizing component imports for $locale" |
| 67 | + node scripts/localize-component-imports.mjs --target "$locale" |
| 68 | + done |
| 69 | +
|
| 70 | + - name: Sync Mintlify heading anchors |
| 71 | + run: node scripts/sync-heading-anchors.mjs |
| 72 | + |
| 73 | + - name: Create translation PR |
| 74 | + uses: peter-evans/create-pull-request@v6 |
| 75 | + with: |
| 76 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 77 | + commit-message: "chore(i18n): update translations from main" |
| 78 | + title: "chore(i18n): update translations from main" |
| 79 | + body: "Automated translation update from main branch push." |
| 80 | + branch: "chore/i18n/auto-translations" |
| 81 | + delete-branch: true |
0 commit comments