From 8b79e1dc1ff6f8b1a39ca023afb69d6d2c0454af Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Mon, 12 Oct 2026 18:20:30 +0200 Subject: [PATCH] Translate the "submodule" label in the files panel Co-Authored-By: Claude Opus 5.5 (1M context) --- pkg/gui/context/working_tree_context.go | 2 +- pkg/gui/presentation/files.go | 7 +++++-- pkg/gui/presentation/files_test.go | 2 +- pkg/i18n/english.go | 2 ++ 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pkg/gui/context/working_tree_context.go b/pkg/gui/context/working_tree_context.go index 706bed3b6..8b428e15b 100644 --- a/pkg/gui/context/working_tree_context.go +++ b/pkg/gui/context/working_tree_context.go @@ -34,7 +34,7 @@ func NewWorkingTreeContext(c *ContextCommon) *WorkingTreeContext { getDisplayStrings := func(_ int, _ int) [][]string { showFileIcons := icons.IsIconEnabled() && c.UserConfig().Gui.ShowFileIcons showNumstat := c.UserConfig().Gui.ShowNumstatInFilesView - lines := presentation.RenderFileTree(viewModel, c.Model().Submodules, showFileIcons, showNumstat, &c.UserConfig().Gui.CustomIcons, c.UserConfig().Gui.ShowRootItemInFileTree) + lines := presentation.RenderFileTree(viewModel, c.Model().Submodules, showFileIcons, showNumstat, &c.UserConfig().Gui.CustomIcons, c.UserConfig().Gui.ShowRootItemInFileTree, c.Tr) return lo.Map(lines, func(line string, _ int) []string { return []string{line} }) diff --git a/pkg/gui/presentation/files.go b/pkg/gui/presentation/files.go index 534229905..ae92890bf 100644 --- a/pkg/gui/presentation/files.go +++ b/pkg/gui/presentation/files.go @@ -10,6 +10,7 @@ import ( "github.com/jesseduffield/lazygit/pkg/gui/filetree" "github.com/jesseduffield/lazygit/pkg/gui/presentation/icons" "github.com/jesseduffield/lazygit/pkg/gui/style" + "github.com/jesseduffield/lazygit/pkg/i18n" "github.com/jesseduffield/lazygit/pkg/theme" "github.com/jesseduffield/lazygit/pkg/utils" ) @@ -26,12 +27,13 @@ func RenderFileTree( showNumstat bool, customIconsConfig *config.CustomIconsConfig, showRootItem bool, + tr *i18n.TranslationSet, ) []string { collapsedPaths := tree.CollapsedPaths() return renderAux(tree.GetRoot().Raw(), collapsedPaths, -1, -1, func(node *filetree.Node[models.File], treeDepth int, visualDepth int, isCollapsed bool) string { fileNode := filetree.NewFileNode(node) - return getFileLine(isCollapsed, fileNode.GetHasUnstagedChanges(), fileNode.GetHasStagedChanges(), treeDepth, visualDepth, showNumstat, showFileIcons, submoduleConfigs, node, customIconsConfig, showRootItem) + return getFileLine(isCollapsed, fileNode.GetHasUnstagedChanges(), fileNode.GetHasStagedChanges(), treeDepth, visualDepth, showNumstat, showFileIcons, submoduleConfigs, node, customIconsConfig, showRootItem, tr) }) } @@ -121,6 +123,7 @@ func getFileLine( node *filetree.Node[models.File], customIconsConfig *config.CustomIconsConfig, showRootItem bool, + tr *i18n.TranslationSet, ) string { name := fileNameAtDepth(node, treeDepth, showRootItem) output := "" @@ -169,7 +172,7 @@ func getFileLine( output += nameColor.Sprint(utils.EscapeSpecialChars(name)) if isSubmodule { - output += theme.DefaultTextColor.Sprint(" (submodule)") + output += theme.DefaultTextColor.Sprint(" (" + tr.SubmoduleLabel + ")") } if file != nil && showNumstat { diff --git a/pkg/gui/presentation/files_test.go b/pkg/gui/presentation/files_test.go index 9a92731a0..da0483541 100644 --- a/pkg/gui/presentation/files_test.go +++ b/pkg/gui/presentation/files_test.go @@ -123,7 +123,7 @@ M file1 for _, path := range s.collapsedPaths { viewModel.ToggleCollapsed(path) } - result := RenderFileTree(viewModel, nil, false, s.showLineChanges, &config.CustomIconsConfig{}, s.showRootItem) + result := RenderFileTree(viewModel, nil, false, s.showLineChanges, &config.CustomIconsConfig{}, s.showRootItem, common.Tr) assert.EqualValues(t, s.expected, result) }) } diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 0fb388216..1eb463cc1 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -103,6 +103,7 @@ type TranslationSet struct { MergeConflictTakeCurrentCommit string MergeConflictTakeIncomingCommit string SubmoduleMergeConflictDescription string + SubmoduleLabel string StageConflictsRangeDisabled string Checkout string CheckoutTooltip string @@ -1268,6 +1269,7 @@ func EnglishTranslationSet() *TranslationSet { MergeConflictTakeCurrentCommit: "Take current commit", MergeConflictTakeIncomingCommit: "Take incoming commit", SubmoduleMergeConflictDescription: "Conflict: the submodule '{{.path}}' was set to a different commit in the current and the incoming changes. Pick which commit to keep.", + SubmoduleLabel: "submodule", StageConflictsRangeDisabled: "Cannot stage a selection that includes files with merge conflicts; resolve them individually with {{.goIntoKey}} first.", Checkout: "Checkout", CheckoutTooltip: "Checkout selected item.",