Localizing the bot
The locale of the bot is set depending on the user's language preference in Slack.
go-i18n manages the translations.
The web page for go-i18n describes the procedures for translating a new language and new messages, but they are describe here too. First get the tool: go get -u github.com/nicksnyder/go-i18n/v2/goi18n. The binary will be installed into $GOPATH.
Translate a new language
If there is a new language to be added:
- Create an empty message file for the new language, for example Finnish:
touch translate.fi.json - Run
goi18n merge active.en.json translate.fi.jsonto populatetranslate.fi.jsonwith the messages to be translated - Translate
translate.fi.jsonand rename it toactive.fi.json - Load
active.fi.jsoninto the bundle
Translate new messages
If there are new strings to be translated:
- Run
goi18n extract -format jsonto updateactive.en.jsonwith new messages - Run
goi18n merge active.*.jsonto generate updatedtranslate.*.jsonfiles - Translate all the messages in the
translate.*.jsonfiles - Run
goi18n merge active.*.json translate.*.jsonto merge the translated messages into the active message files