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) <noreply@anthropic.com>
This commit is contained in:
Stefan Haller 2026-09-14 10:13:39 +02:00
parent 3452d41fe2
commit 8d0f81cc15
3 changed files with 5 additions and 1 deletions

View file

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

View file

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

View file

@ -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",