diff --git a/pkg/app/app.go b/pkg/app/app.go index bbe714458..a999a902b 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -63,13 +63,10 @@ func Run( func NewCommon(config config.AppConfigurer) (*common.Common, error) { userConfig := config.GetUserConfig() appState := config.GetAppState() - - var err error log := newLogger(config) - tr, err := i18n.NewTranslationSetFromConfig(log, userConfig.Gui.Language) - if err != nil { - return nil, err - } + // Initialize with English for the time being; the real translation set for + // the configured language will be read after reading the user config + tr := i18n.EnglishTranslationSet() cmn := &common.Common{ Log: log, diff --git a/pkg/cheatsheet/generate.go b/pkg/cheatsheet/generate.go index 5f0d7549d..100245f62 100644 --- a/pkg/cheatsheet/generate.go +++ b/pkg/cheatsheet/generate.go @@ -63,6 +63,11 @@ func generateAtDir(cheatsheetDir string) { if err != nil { log.Fatal(err) } + tr, err := i18n.NewTranslationSetFromConfig(common.Log, lang) + if err != nil { + log.Fatal(err) + } + common.Tr = tr mApp, _ := app.NewApp(mConfig, nil, common) path := cheatsheetDir + "/Keybindings_" + lang + ".md" file, err := os.Create(path) diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 015aec1fa..582047ab9 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -36,6 +36,7 @@ import ( "github.com/jesseduffield/lazygit/pkg/gui/status" "github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/gui/types" + "github.com/jesseduffield/lazygit/pkg/i18n" "github.com/jesseduffield/lazygit/pkg/integration/components" integrationTypes "github.com/jesseduffield/lazygit/pkg/integration/types" "github.com/jesseduffield/lazygit/pkg/tasks" @@ -138,6 +139,8 @@ type Gui struct { c *helpers.HelperCommon helpers *helpers.Helpers + previousLanguageConfig string + integrationTest integrationTypes.IntegrationTest afterLayoutFuncs chan func() error @@ -383,6 +386,15 @@ func (gui *Gui) onUserConfigLoaded() error { gui.setColorScheme() gui.configureViewProperties() + if gui.previousLanguageConfig != userConfig.Gui.Language { + tr, err := i18n.NewTranslationSetFromConfig(gui.Log, userConfig.Gui.Language) + if err != nil { + return err + } + gui.c.Tr = tr + gui.previousLanguageConfig = userConfig.Gui.Language + } + return nil }