mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-03-05 15:15:49 +02:00
Put all worktree i18n strings together
Use tabwriter to align worktree panel contents
This commit is contained in:
parent
54708233ac
commit
35e6e6347a
@ -2,6 +2,8 @@ package controllers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
"text/tabwriter"
|
||||||
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/context"
|
"github.com/jesseduffield/lazygit/pkg/gui/context"
|
||||||
@ -53,27 +55,32 @@ func (self *WorktreesController) GetOnRenderToMain() func() error {
|
|||||||
var task types.UpdateTask
|
var task types.UpdateTask
|
||||||
worktree := self.context().GetSelected()
|
worktree := self.context().GetSelected()
|
||||||
if worktree == nil {
|
if worktree == nil {
|
||||||
task = types.NewRenderStringTask("No worktrees")
|
task = types.NewRenderStringTask(self.c.Tr.NoWorktreesThisRepo)
|
||||||
} else {
|
} else {
|
||||||
|
main := ""
|
||||||
|
if worktree.Main() {
|
||||||
|
main = style.FgDefault.Sprintf(" %s", self.c.Tr.MainWorktree)
|
||||||
|
}
|
||||||
|
|
||||||
missing := ""
|
missing := ""
|
||||||
if worktree.Missing() {
|
if worktree.Missing() {
|
||||||
missing = style.FgRed.Sprint(" (missing)")
|
missing = style.FgRed.Sprintf(" %s", self.c.Tr.MissingWorktree)
|
||||||
}
|
}
|
||||||
task = types.NewRenderStringTask(
|
|
||||||
fmt.Sprintf(
|
var builder strings.Builder
|
||||||
"Name: %s\nBranch: %s\nPath: %s%s\n",
|
w := tabwriter.NewWriter(&builder, 0, 0, 2, ' ', 0)
|
||||||
style.FgGreen.Sprint(worktree.Name()),
|
_, _ = fmt.Fprintf(w, "%s:\t%s%s\n", self.c.Tr.Name, style.FgGreen.Sprint(worktree.Name()), main)
|
||||||
style.FgYellow.Sprint(worktree.Branch),
|
_, _ = fmt.Fprintf(w, "%s:\t%s\n", self.c.Tr.Branch, style.FgYellow.Sprint(worktree.Branch))
|
||||||
style.FgCyan.Sprint(worktree.Path),
|
_, _ = fmt.Fprintf(w, "%s:\t%s%s\n", self.c.Tr.Path, style.FgCyan.Sprint(worktree.Path), missing)
|
||||||
missing,
|
_ = w.Flush()
|
||||||
),
|
|
||||||
)
|
task = types.NewRenderStringTask(builder.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.c.RenderToMainViews(types.RefreshMainOpts{
|
return self.c.RenderToMainViews(types.RefreshMainOpts{
|
||||||
Pair: self.c.MainViewPairs().Normal,
|
Pair: self.c.MainViewPairs().Normal,
|
||||||
Main: &types.ViewUpdateOpts{
|
Main: &types.ViewUpdateOpts{
|
||||||
Title: "Worktree",
|
Title: self.c.Tr.WorktreeTitle,
|
||||||
Task: task,
|
Task: task,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -200,7 +200,6 @@ type TranslationSet struct {
|
|||||||
TagsTitle string
|
TagsTitle string
|
||||||
MenuTitle string
|
MenuTitle string
|
||||||
RemotesTitle string
|
RemotesTitle string
|
||||||
WorktreesTitle string
|
|
||||||
RemoteBranchesTitle string
|
RemoteBranchesTitle string
|
||||||
PatchBuildingTitle string
|
PatchBuildingTitle string
|
||||||
InformationTitle string
|
InformationTitle string
|
||||||
@ -546,10 +545,18 @@ type TranslationSet struct {
|
|||||||
EnterWorktree string
|
EnterWorktree string
|
||||||
DeleteWorktree string
|
DeleteWorktree string
|
||||||
DeleteWorktreeTitle string
|
DeleteWorktreeTitle string
|
||||||
|
WorktreesTitle string
|
||||||
|
WorktreeTitle string
|
||||||
DeleteWorktreePrompt string
|
DeleteWorktreePrompt string
|
||||||
ForceDeleteWorktreePrompt string
|
ForceDeleteWorktreePrompt string
|
||||||
CantDeleteCurrentWorktree string
|
CantDeleteCurrentWorktree string
|
||||||
CantDeleteMainWorktree string
|
CantDeleteMainWorktree string
|
||||||
|
NoWorktreesThisRepo string
|
||||||
|
MissingWorktree string
|
||||||
|
MainWorktree string
|
||||||
|
Name string
|
||||||
|
Branch string
|
||||||
|
Path string
|
||||||
Actions Actions
|
Actions Actions
|
||||||
Bisect Bisect
|
Bisect Bisect
|
||||||
}
|
}
|
||||||
@ -907,7 +914,6 @@ func EnglishTranslationSet() TranslationSet {
|
|||||||
TagsTitle: "Tags",
|
TagsTitle: "Tags",
|
||||||
MenuTitle: "Menu",
|
MenuTitle: "Menu",
|
||||||
RemotesTitle: "Remotes",
|
RemotesTitle: "Remotes",
|
||||||
WorktreesTitle: "Worktrees",
|
|
||||||
RemoteBranchesTitle: "Remote branches",
|
RemoteBranchesTitle: "Remote branches",
|
||||||
PatchBuildingTitle: "Main panel (patch building)",
|
PatchBuildingTitle: "Main panel (patch building)",
|
||||||
InformationTitle: "Information",
|
InformationTitle: "Information",
|
||||||
@ -1251,6 +1257,8 @@ func EnglishTranslationSet() TranslationSet {
|
|||||||
SearchKeybindings: "%s: Next match, %s: Previous match, %s: Exit search mode",
|
SearchKeybindings: "%s: Next match, %s: Previous match, %s: Exit search mode",
|
||||||
SearchPrefix: "Search: ",
|
SearchPrefix: "Search: ",
|
||||||
FilterPrefix: "Filter: ",
|
FilterPrefix: "Filter: ",
|
||||||
|
WorktreesTitle: "Worktrees",
|
||||||
|
WorktreeTitle: "Worktree",
|
||||||
EnterWorktree: "Enter worktree",
|
EnterWorktree: "Enter worktree",
|
||||||
DeleteWorktree: "Delete worktree",
|
DeleteWorktree: "Delete worktree",
|
||||||
DeleteWorktreeTitle: "Delete worktree",
|
DeleteWorktreeTitle: "Delete worktree",
|
||||||
@ -1258,6 +1266,12 @@ func EnglishTranslationSet() TranslationSet {
|
|||||||
ForceDeleteWorktreePrompt: "'{{.worktreeName}}' is not fully merged. Are you sure you want to delete it?",
|
ForceDeleteWorktreePrompt: "'{{.worktreeName}}' is not fully merged. Are you sure you want to delete it?",
|
||||||
CantDeleteCurrentWorktree: "You cannot delete the current worktree!",
|
CantDeleteCurrentWorktree: "You cannot delete the current worktree!",
|
||||||
CantDeleteMainWorktree: "You cannot delete the main worktree!",
|
CantDeleteMainWorktree: "You cannot delete the main worktree!",
|
||||||
|
NoWorktreesThisRepo: "No worktrees",
|
||||||
|
MissingWorktree: "(missing)",
|
||||||
|
MainWorktree: "(main)",
|
||||||
|
Name: "Name",
|
||||||
|
Branch: "Branch",
|
||||||
|
Path: "Path",
|
||||||
Actions: Actions{
|
Actions: Actions{
|
||||||
// TODO: combine this with the original keybinding descriptions (those are all in lowercase atm)
|
// TODO: combine this with the original keybinding descriptions (those are all in lowercase atm)
|
||||||
CheckoutCommit: "Checkout commit",
|
CheckoutCommit: "Checkout commit",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user