From 8d0f81cc1561b743e6455c8d5876bcdb03420af0 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Mon, 14 Sep 2026 10:13:39 +0200 Subject: [PATCH] Make the worktrees panel's detached-head text translatable The recent repos menu is about to show the same text for a repo that has no branch checked out. Hardcoding the English a second time would leave translators with one of the two copies, so give the text a translation key and take it from there in both places. Co-Authored-By: Claude Opus 5 (1M context) --- pkg/gui/presentation/worktrees.go | 3 ++- pkg/gui/presentation/worktrees_test.go | 1 + pkg/i18n/english.go | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/gui/presentation/worktrees.go b/pkg/gui/presentation/worktrees.go index b2d99cb95..d0a506690 100644 --- a/pkg/gui/presentation/worktrees.go +++ b/pkg/gui/presentation/worktrees.go @@ -49,7 +49,8 @@ func GetWorktreeDisplayString(tr *i18n.TranslationSet, worktree *models.Worktree if worktree.Branch != "" { branch = style.FgCyan.Sprint(worktree.Branch) } else if worktree.Head != "" { - branch = style.FgYellow.Sprint("HEAD detached at " + utils.ShortHash(worktree.Head)) + branch = style.FgYellow.Sprint(utils.ResolvePlaceholderString( + tr.HeadDetachedAt, map[string]string{"hash": utils.ShortHash(worktree.Head)})) } res = append(res, branch+mainWorktreeLabel(tr, worktree)) return res diff --git a/pkg/gui/presentation/worktrees_test.go b/pkg/gui/presentation/worktrees_test.go index 73abe100d..a7b1ab4a5 100644 --- a/pkg/gui/presentation/worktrees_test.go +++ b/pkg/gui/presentation/worktrees_test.go @@ -14,6 +14,7 @@ func Test_GetWorktreeDisplayString(t *testing.T) { tr := &i18n.TranslationSet{ MainWorktree: "(main worktree)", MissingWorktree: "(missing)", + HeadDetachedAt: "HEAD detached at {{.hash}}", } scenarios := []struct { diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 0f33d9bc0..7a39cd716 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -718,6 +718,7 @@ type TranslationSet struct { BranchNotFoundTitle string BranchNotFoundPrompt string BranchUnknown string + HeadDetachedAt string DiscardChangeTitle string DiscardChangePrompt string DiscardLinesFromCommitTitle string @@ -1884,6 +1885,7 @@ func EnglishTranslationSet() *TranslationSet { BranchNotFoundTitle: "Branch not found", BranchNotFoundPrompt: "Branch not found. Create a new branch named", BranchUnknown: "Branch unknown", + HeadDetachedAt: "HEAD detached at {{.hash}}", DiscardChangeTitle: "Discard change", DiscardChangePrompt: "Are you sure you want to discard this change (git reset)? It is irreversible.\nTo disable this dialogue set the config key of 'gui.skipDiscardChangeWarning' to true", DiscardLinesFromCommitTitle: "Discard lines from commit",