Extract messages: Run goi18n extract to generate a base message file (e.g., en.toml) from your Go code.
Example en.toml structure:
[PersonCats]
description = "The number of cats a person has"
one = "{{.Name}} has {{.Count}} cat."
other = "{{.Name}} has {{.Count}} cats."
Prepare for translation: Run goi18n merge to create a template file for translators (e.g., translate.es.toml). This file includes a hash to track message changes.
Example translate.es.toml structure:
[PersonCats]
description = "The number of cats a person has"
hash = "sha1-f937a0e05e19bfe6cd70937c980eaf1f9832f091"
one = "{{.Name}} has {{.Count}} cat."
other = "{{.Name}} has {{.Count}} cats."
Merge translations: Once translated, run goi18n merge to merge the translations into your active message file (e.g., active.es.toml).
Example active.es.toml structure:
[PersonCats]
description = "The number of cats a person has"
hash = "sha1-f937a0e05e19bfe6cd70937c980eaf1f9832f091"
one = "{{.Name}} tiene {{.Count}} gato."
other = "{{.Name}} tiene {{.Count}} gatos."