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.json
to populatetranslate.fi.json
with the messages to be translated - Translate
translate.fi.json
and rename it toactive.fi.json
- Load
active.fi.json
into the bundle
Translate new messages
If there are new strings to be translated:
- Run
goi18n extract -format json
to updateactive.en.json
with new messages - Run
goi18n merge active.*.json
to generate updatedtranslate.*.json
files - Translate all the messages in the
translate.*.json
files - Run
goi18n merge active.*.json translate.*.json
to merge the translated messages into the active message files