Translations in Goat
View catalogues, message parameters, plural forms and documentation translation.
GoatCMS supports pl, en, de and zh, with en configured as the default application language in herd/_model.goat. The public 0.1 documentation uses Polish as the source for its translation recipe. Edit the source used by the feature that renders the text.
| Content | Source |
|---|---|
| Portable view labels, controls, validation and feedback | herd/views/*.translations.goat and shared core messages. |
| Text in Goat-generated catalogues | herd/gen/translations.goat and module translation scripts. |
| Project-specific pages such as the GoatCMS homepage | Project assets such as child/static/raw/data/i18n/home.<lang>.json. |
| Public documentation | Markdown under herd/fixtures/doc/0.1/<lang>/, the fixture registry and link map. |
Portable-ui messages
Use translations:define with a message:add per key and a locale:add per language. The key is part of the contract. Use snake_case segments separated by dots, as in search_panel.result_title. This excerpt declares a typed parameter.
translations:define --body=<<MESSAGES
message:add --key=example.result_title --parameters=<<PARAMETERS
add --name=title --type=short_text --required
PARAMETERS --body=<<LOCALES
locale:add --language=pl --text="{{title}}"
locale:add --language=en --text="{{title}}"
locale:add --language=de --text="{{title}}"
locale:add --language=zh --text="{{title}}"
LOCALES
MESSAGESInside a list row, text:set --role=label --key=example.result_title --parameters=<<PARAMETERS passes it through bind --name=title --from=item.title. Match the name and type and preserve the placeholder in every locale. Values come from the typed view context. When a user switches language, the runtime recalculates the text and the form can retain its state and draft.
To declare plurals, use locale:add --forms=<<FORMS with form:add --name=.... search_panel.summary in search.translations.goat binds count and other totals to read data. All four languages have other. EN and DE also use one. PL also uses one, few and many. Choose the correct forms for the language and exercise values such as 1, 2, 5 and 21. An intentional replacement requires explicit --override and compatible parameters. Reference existing core validation messages by key.
Generator translation catalogues
translate:json groups keys into a selected output such as main.json. --source-lang declares the source language and --context explains the group. --language=pl --fixed records reviewed texts for a language. Synchronization preserves fixed entries even on a forced refresh. It compares generated entries with a source fingerprint and checks placeholders before writing.
translate:json --out="main.json" --source-lang=en --context="Search toolbar" --body=<<EN
example.search = "Search"
EN
translate:json --out="main.json" --language=pl --fixed --body=<<PL
example.search = "Szukaj"
PLThe generator collects catalogues under .goat/cache/translations/ and emits application assets to goatapp/static/raw/data/i18n/. @goatcms/herd/translate.goat runs translate:sync for main.json and entities.json. Here, herd/project.json chooses the provider and model. Synchronizing requires access to the provider. The OpenAI key comes from GOAT_OPENAI_API_KEY. Refresh derived foundation catalogues through generation and the translation recipe.
Translating public documentation
- Write the Polish Markdown and EN, DE and ZH versions in
herd/fixtures/doc/0.1/<lang>/. - Register each with
crud:doc:persistinherd/fixtures/doc/fixture.goat. Provide the language, version, slug, title, description and path. All versions of one topic share atranslation_key. - In
translation-links.json, map the Polish/doc/pl/<slug>URL to translated URLs. Add three corresponding steps intranslate-docs.goatand make the new section reachable from each language’s start page. - Review all four versions. Preserve code syntax, identifiers, arguments and localized links. Review existing translations alongside changes to the Polish source. The recipe’s
--skip-existingflag makes it fill missing files only. - Validate the registry and navigation. To see the content in the running application, import the
docfixture section into the target environment following the fixture procedure and its approval requirements.
goat run:script --path=herd/ci/docs.goatThe documentation check covers language completeness, registered URLs and files, reachability, URL mappings and translation declarations. View validation checks references to the message catalogue. After an interface change, open the screen in all four languages and check wrapping, accessibility labels, errors and number and date formatting.