diff options
author | Ruben Pollan <meskio@sindominio.net> | 2018-02-21 12:06:58 +0100 |
---|---|---|
committer | Ruben Pollan <meskio@sindominio.net> | 2018-02-21 15:46:21 +0100 |
commit | 868b796e77146e259c36789666282007cf80cc9b (patch) | |
tree | a6847eec043757fd4a386ec19002ca1fad1d7966 /main.go | |
parent | e843f609fcedc9d5bc15c762429bca9cc3c3f8b0 (diff) |
[feat] add i18n support
Using golang.org/x/text, wich is still in early stages of development,
but seems to work good enough for our needs.
- Resolves: #2
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -19,17 +19,22 @@ import ( "log" "0xacab.org/leap/bitmask-systray/bitmask" + "github.com/jmshal/go-locale" + "golang.org/x/text/message" ) const ( provider = "riseup.net" ) +var printer *message.Printer + func main() { conf, err := parseConfig() if err != nil { log.Fatal(err) } + initPrinter() notify := newNotificator(conf) @@ -60,3 +65,12 @@ func checkAndInstallHelpers(b *bitmask.Bitmask, notify *notificator) { } } } + +func initPrinter() { + locale, err := go_locale.DetectLocale() + if err != nil { + log.Println("Error detecting the system locale: ", err) + } + + printer = message.NewPrinter(message.MatchLanguage(locale, "en")) +} |