From 868b796e77146e259c36789666282007cf80cc9b Mon Sep 17 00:00:00 2001 From: Ruben Pollan Date: Wed, 21 Feb 2018 12:06:58 +0100 Subject: [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 --- main.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'main.go') diff --git a/main.go b/main.go index e1b2a56..d483c26 100644 --- a/main.go +++ b/main.go @@ -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")) +} -- cgit v1.2.3