Expand description
Machine translation of gettext catalogs and Markdown readmes through the Claude API, for apps that use patois.
translate syncs each .po file with the .pot through msgmerge, and then asks Claude to
fill the blank entries. Each request includes the TRANSLATORS: note of each string, and each
answer goes through patois_build::check, so a translation that loses a placeholder, an
accelerator, or a shortcut is never written. The function can also translate a readme into
readme-<lang>.md files, one section at a time.
Call it from an xtask after you regenerate the .pot. It needs msgmerge from gettext and,
unless it’s a dry run, an ANTHROPIC_API_KEY. To use a model other than the default, set
PATOIS_TRANSLATE_MODEL.
Two optional files in the .po directory change what it does:
human-maintained-locales.txt: locales that people translate, one per line. The function skips them.style/<lang>.md: conventions for one language, which are added to its instructions.
Structs§
- App
- The app that the model translates for.
- Options
- Options for
translate. - Project
- Where a project keeps its translations. The paths other than
rootare relative toroot.
Functions§
- translate
- Translates every
.pofile ofprojectthat isn’t human-maintained, then its readme.