From 0c39347224335998fd38cdad2feb23f55d3a5516 Mon Sep 17 00:00:00 2001 From: Mark Kopenga Date: Tue, 14 Aug 2018 12:52:26 +0200 Subject: Added auto detection for the system language --- pkg/gui/files_panel.go | 2 +- pkg/i18n/dutch.go | 5 ++++- pkg/i18n/i18n.go | 10 ++++------ 3 files changed, 9 insertions(+), 8 deletions(-) (limited to 'pkg') diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go index ad8ee6fbc..ba60a3278 100644 --- a/pkg/gui/files_panel.go +++ b/pkg/gui/files_panel.go @@ -168,7 +168,7 @@ func (gui *Gui) renderfilesOptions(g *gocui.Gui, file *commands.File) error { return gui.renderOptionsMap(g, optionsMap) } if file.Tracked { - optionsMap["d"] = "checkout" + optionsMap["d"] = lang.SLocalize("checkout", "checkout") } return gui.renderOptionsMap(g, optionsMap) } diff --git a/pkg/i18n/dutch.go b/pkg/i18n/dutch.go index 9a847b573..10d01c6df 100644 --- a/pkg/i18n/dutch.go +++ b/pkg/i18n/dutch.go @@ -6,7 +6,7 @@ import ( ) func addDutch(i18nObject *i18n.Bundle) *i18n.Bundle { - i18nObject.AddMessages(language.English, + i18nObject.AddMessages(language.Dutch, &i18n.Message{ ID: "NotEnoughSpace", Other: "Niet genoeg ruimte om de panelen te renderen", @@ -70,6 +70,9 @@ func addDutch(i18nObject *i18n.Bundle) *i18n.Bundle { }, &i18n.Message{ ID: "resolveMergeConflicts", Other: "verhelp samenvoegen fouten", + }, &i18n.Message{ + ID: "checkout", + Other: "uitchecken", }, ) return i18nObject diff --git a/pkg/i18n/i18n.go b/pkg/i18n/i18n.go index c743218f8..ffd77fde6 100644 --- a/pkg/i18n/i18n.go +++ b/pkg/i18n/i18n.go @@ -1,7 +1,7 @@ package lang import ( - "github.com/BurntSushi/toml" + "github.com/cloudfoundry/jibber_jabber" "github.com/nicksnyder/go-i18n/v2/i18n" "golang.org/x/text/language" ) @@ -9,15 +9,13 @@ import ( // the function to setup the localizer func getlocalizer() *i18n.Localizer { - // TODO: currently the system language issn't detected - // I'm not sure how to detect it - var i18nObject = &i18n.Bundle{DefaultLanguage: language.Dutch} - i18nObject.RegisterUnmarshalFunc("toml", toml.Unmarshal) + userLang, _ := jibber_jabber.DetectLanguage() + var i18nObject = &i18n.Bundle{DefaultLanguage: language.English} // add translation file(s) i18nObject = addDutch(i18nObject) - return i18n.NewLocalizer(i18nObject) + return i18n.NewLocalizer(i18nObject, userLang) } // setup the localizer for later use -- cgit v1.2.3