Scroll to navigation

GOI18N(1) goi18n Manual GOI18N(1)

NAME

goi18n - a tool for managing message translations

SYNOPSIS

goi18n command [arguments]

DESCRIPTION

The goi18n command manages message files used by the i18n (github.com/nicksnyder/go-i18n/v2/i18n) Go package.

WORKFLOW

Extracting messages

# active.en.toml
[PersonCats]
description = "The number of cats a person has"
one = "{{.Name}} has {{.Count}} cat."
other = "{{.Name}} has {{.Count}} cats."
    

Translating a new language

1.
Create an empty message file for the language that you want to add (e.g. translate.es.toml).
2.
Run “goi18n merge active.en.toml translate.es.toml” to populate translate.es.toml with the mesages to be translated.
# translate.es.toml
[PersonCats]
description = "The number of cats a person has"
hash = "sha1-f937a0e05e19bfe6cd70937c980eaf1f9832f091"
one = "{{.Name}} has {{.Count}} cat."
other = "{{.Name}} has {{.Count}} cats."
    
3.
After translate.es.toml has been translated, rename it to active.es.toml.
# active.es.toml
[PersonCats]
description = "The number of cats a person has"
hash = "sha1-f937a0e05e19bfe6cd70937c980eaf1f9832f091"
one = "{{.Name}} tiene {{.Count}} gato."
other = "{{.Name}} tiene {{.Count}} gatos."
    
4.
Load active.es.toml into your bundle.
bundle.RegisterUnmarshalFunc("toml", toml.Unmarshal)
bundle.MustLoadMessageFile("active.es.toml")
    

Translating new messages

If you have added new messages to your program:

1.
Run “goi18n extract” to update active.en.toml with the new messages.
2.
Run “goi18n merge active.*.toml” to generate updated translate.*.toml files.
3.
Translate all the messages in the translate.*.toml files.
4.
Run “goi18n merge active.*.toml translate.*.toml” to merge the translated messages into the active message files.

AUTHOR

goi18n is written by Nick Snyder.

This manual page is prepared for Debian by Anthony Fok using information from upstream README.md and output of goi18n -help.

COPYRIGHT

Copyright © 2012–2020 Nick Snyder
License: MIT (Expat)

SEE ALSO

Full documentation at https://github.com/nicksnyder/go-i18n

2020-10-29 goi18n (v2)