Skip to content

[Localization] Auto-translation bot: Claude API + GitHub Actions pipeline #2871

Description

@github-actions

Summary

Set up an automated GitHub Actions workflow that detects new or changed English strings and auto-translates them using the Claude API (or DeepL), opening a PR with draft translations for admin review before merge.

Background

The hardest ongoing maintenance problem with localization is keeping translations up to date as new strings are added. This ticket designs and implements a low-cost automation that:

  1. Detects when en.lproj/Localizable.strings changes on the develop branch
  2. Identifies which keys are new or changed
  3. Uses Claude (claude-haiku-4-5 for cost efficiency) to translate those keys into all supported languages
  4. Opens a draft PR with the new translations for @JoeMatt to review and merge

Design

Workflow trigger

on:
  push:
    branches: [develop]
    paths:
      - '**/en.lproj/Localizable.strings'
      - '**/en.lproj/Strings.strings'

Translation script (Scripts/auto_translate.py or Swift)

  • Reads the diff of strings files
  • Calls Claude API with prompt: "Translate these iOS app strings from English to {language}. Return only the .strings file format. Preserve format arguments like %@, %d. Do not translate proper nouns like 'Provenance', 'RetroArch', button names."
  • Languages: zh-Hans, ja, ko, es, pt-BR, de, fr, it, nl, ru, ar
  • Outputs translated .strings entries

Cost control

  • Only translate new/changed keys (delta, not full file)
  • Use claude-haiku-4-5-20251001 (cheapest model) for batch translations
  • Estimated cost: <$0.01 per translation run for typical string additions

PR creation

  • Draft PR titled "[Auto-translation] New strings for {languages}"
  • Body includes diff of changes + a checklist for each language to review
  • Label: translations,needs-review
  • Assigned to @JoeMatt

Tasks

  • Create Scripts/auto_translate.py (or .sh wrapper) using Anthropic Python SDK
  • Create .github/workflows/auto-translate.yml workflow
  • Add ANTHROPIC_API_KEY to repo Actions secrets (document in DEVELOPER.md)
  • Test on a branch with a few new English strings
  • Add a <!-- translation-skip --> comment convention for strings that should not be auto-translated
  • Document the workflow in DEVELOPER.md under a "Localization" section

Languages Priority

Phase 1 (most requested): zh-Hans, ja, ko, de, es, pt-BR
Phase 2 (existing): it, nl, ru
Phase 3 (new): ar, fr

Acceptance Criteria

  • Pushing a change to any en.lproj/*.strings file triggers the workflow
  • A draft PR appears within 5 minutes with translated strings
  • The PR body lists which keys were translated and which were skipped
  • Admin can merge directly or edit strings before merging
  • Cost per run is <$0.05

Cost Estimate

  • ~200 new strings per release × 10 languages × ~20 tokens each = ~40,000 tokens
  • At Haiku rates (~$0.25/MTok input): ~$0.01 per full translation run

Part of #2862

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions