Initialize translation set after reading user config

This allows having per-repo config files with different languages per repo. Now
granted, this is not an important use case that we need to support; however, the
goal is to eventually make all configs hot-reloadable (as opposed to loading
them only once at startup), so this is one step in that direction.
This commit is contained in:
Stefan Haller 2024-07-27 21:39:46 +02:00
parent 74ed1ac584
commit 2499a6c8a3
3 changed files with 20 additions and 6 deletions

View file

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