1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-02-09 13:47:11 +02:00

Added auto detection for the system language

This commit is contained in:
Mark Kopenga 2018-08-14 12:52:26 +02:00
parent dd7e93ac8d
commit 0c39347224
3 changed files with 9 additions and 8 deletions

View File

@ -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)
}

View File

@ -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

View File

@ -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