diff --git a/pkg/gui/controllers/branches_controller.go b/pkg/gui/controllers/branches_controller.go index f85bd49fa..e7023959f 100644 --- a/pkg/gui/controllers/branches_controller.go +++ b/pkg/gui/controllers/branches_controller.go @@ -216,9 +216,13 @@ func (self *BranchesController) worktreeForBranch(branch *models.Branch) (*model } func (self *BranchesController) promptToCheckoutWorktree(worktree *models.Worktree) error { + prompt := utils.ResolvePlaceholderString(self.c.Tr.AlreadyCheckedOutByWorktree, map[string]string{ + "worktreeName": worktree.Name, + }) + return self.c.Confirm(types.ConfirmOpts{ - Title: "Switch to worktree", - Prompt: fmt.Sprintf("This branch is checked out by worktree %s. Do you want to switch to that worktree?", worktree.Name), + Title: self.c.Tr.SwitchToWorktree, + Prompt: prompt, HandleConfirm: func() error { return self.c.Helpers().Worktree.Switch(worktree, context.LOCAL_BRANCHES_CONTEXT_KEY) }, @@ -332,28 +336,33 @@ func (self *BranchesController) checkedOutByOtherWorktree(branch *models.Branch) func (self *BranchesController) promptWorktreeBranchDelete(selectedBranch *models.Branch) error { worktree, ok := self.worktreeForBranch(selectedBranch) if !ok { - self.c.Log.Error("CheckedOutByOtherWorktree out of sync with list of worktrees") + self.c.Log.Error("promptWorktreeBranchDelete out of sync with list of worktrees") return nil } + // TODO: i18n + title := utils.ResolvePlaceholderString(self.c.Tr.BranchCheckedOutByWorktree, map[string]string{ + "worktreeName": worktree.Name, + "branchName": selectedBranch.Name, + }) return self.c.Menu(types.CreateMenuOptions{ - Title: fmt.Sprintf("Branch %s is checked out by worktree %s", selectedBranch.Name, worktree.Name), + Title: title, Items: []*types.MenuItem{ { - Label: "Switch to worktree", + Label: self.c.Tr.SwitchToWorktree, OnPress: func() error { return self.c.Helpers().Worktree.Switch(worktree, context.LOCAL_BRANCHES_CONTEXT_KEY) }, }, { - Label: "Detach worktree", - Tooltip: "This will run `git checkout --detach` on the worktree so that it stops hogging the branch, but the worktree's working tree will be left alone", + Label: self.c.Tr.DetachWorktree, + Tooltip: self.c.Tr.DetachWorktreeTooltip, OnPress: func() error { return self.c.Helpers().Worktree.Detach(worktree) }, }, { - Label: "Remove worktree", + Label: self.c.Tr.RemoveWorktree, OnPress: func() error { return self.c.Helpers().Worktree.Remove(worktree, false) }, diff --git a/pkg/gui/controllers/helpers/repos_helper.go b/pkg/gui/controllers/helpers/repos_helper.go index 0faa0e16b..939d7eb05 100644 --- a/pkg/gui/controllers/helpers/repos_helper.go +++ b/pkg/gui/controllers/helpers/repos_helper.go @@ -151,7 +151,8 @@ func (self *ReposHelper) DispatchSwitchTo(path string, errMsg string, contextKey return nil } - self.c.LogCommand(fmt.Sprintf("Changing directory to %s", path), false) + msg := utils.ResolvePlaceholderString(self.c.Tr.ChangingDirectoryTo, map[string]string{"path": path}) + self.c.LogCommand(msg, false) if err := os.Chdir(path); err != nil { if os.IsNotExist(err) { diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 6e5498942..ecfa6a2ae 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -544,6 +544,9 @@ type TranslationSet struct { ExitSearchMode string ExitTextFilterMode string SwitchToWorktree string + AlreadyCheckedOutByWorktree string + BranchCheckedOutByWorktree string + DetachWorktreeTooltip string Switching string RemoveWorktree string RemoveWorktreeTitle string @@ -571,6 +574,7 @@ type TranslationSet struct { CreateWorktreeFrom string CreateWorktreeFromDetached string LcWorktree string + ChangingDirectoryTo string Name string Branch string Path string @@ -1279,6 +1283,9 @@ func EnglishTranslationSet() TranslationSet { WorktreesTitle: "Worktrees", WorktreeTitle: "Worktree", SwitchToWorktree: "Switch to worktree", + AlreadyCheckedOutByWorktree: "This branch is checked out by worktree {{.worktreeName}}. Do you want to switch to that worktree?", + BranchCheckedOutByWorktree: "Branch {{.branchName}} is checked out by worktree {{.worktreeName}}", + DetachWorktreeTooltip: "This will run `git checkout --detach` on the worktree so that it stops hogging the branch, but the worktree's working tree will be left alone", Switching: "Switching", RemoveWorktree: "Remove worktree", RemoveWorktreeTitle: "Remove worktree", @@ -1304,6 +1311,7 @@ func EnglishTranslationSet() TranslationSet { CreateWorktreeFrom: "Create worktree from {{.ref}}", CreateWorktreeFromDetached: "Create worktree from {{.ref}} (detached)", LcWorktree: "worktree", + ChangingDirectoryTo: "Changing directory to {{.path}}", Name: "Name", Branch: "Branch", Path: "Path",