mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-02-07 13:42:01 +02:00
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:
parent
74ed1ac584
commit
2499a6c8a3
@ -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,
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user