diff --git a/pkg/commands/models/working_tree_state.go b/pkg/commands/models/working_tree_state.go index 3e7bdbf1b..12b07b1f1 100644 --- a/pkg/commands/models/working_tree_state.go +++ b/pkg/commands/models/working_tree_state.go @@ -94,6 +94,17 @@ func (self WorkingTreeState) OptionsMapTitle(tr *i18n.TranslationSet) string { }[self.Effective()] } +// OperationName returns a phrase for the current operation that we can use in +// sentences like "Abort ". +func (self WorkingTreeState) OperationName(tr *i18n.TranslationSet) string { + return map[EffectiveWorkingTreeState]string{ + WORKING_TREE_STATE_REBASING: tr.RebaseOperationName, + WORKING_TREE_STATE_MERGING: tr.MergeOperationName, + WORKING_TREE_STATE_CHERRY_PICKING: tr.CherryPickOperationName, + WORKING_TREE_STATE_REVERTING: tr.RevertOperationName, + }[self.Effective()] +} + func (self WorkingTreeState) CommandName() string { return map[EffectiveWorkingTreeState]string{ WORKING_TREE_STATE_REBASING: "rebase", diff --git a/pkg/gui/controllers/helpers/merge_and_rebase_helper.go b/pkg/gui/controllers/helpers/merge_and_rebase_helper.go index 106652ff3..12b98e3ce 100644 --- a/pkg/gui/controllers/helpers/merge_and_rebase_helper.go +++ b/pkg/gui/controllers/helpers/merge_and_rebase_helper.go @@ -283,7 +283,7 @@ func (self *MergeAndRebaseHelper) CheckForConflicts(result error) error { } func (self *MergeAndRebaseHelper) PromptForConflictHandling() error { - mode := self.c.Git().Status.WorkingTreeState().CommandName() + operation := self.c.Git().Status.WorkingTreeState().OperationName(self.c.Tr) return self.c.Menu(types.CreateMenuOptions{ Title: self.c.Tr.FoundConflictsTitle, Items: []*types.MenuItem{ @@ -295,7 +295,8 @@ func (self *MergeAndRebaseHelper) PromptForConflictHandling() error { }, }, { - Label: fmt.Sprintf(self.c.Tr.AbortMenuItem, mode), + Label: utils.ResolvePlaceholderString(self.c.Tr.AbortOperationMenuItem, + map[string]string{"operation": operation}), OnPress: func() error { return self.genericMergeCommand(REBASE_OPTION_ABORT) }, @@ -308,10 +309,12 @@ func (self *MergeAndRebaseHelper) PromptForConflictHandling() error { func (self *MergeAndRebaseHelper) AbortMergeOrRebaseWithConfirm() error { // prompt user to confirm that they want to abort, then do it - mode := self.c.Git().Status.WorkingTreeState().CommandName() + placeholders := map[string]string{ + "operation": self.c.Git().Status.WorkingTreeState().OperationName(self.c.Tr), + } self.c.Confirm(types.ConfirmOpts{ - Title: fmt.Sprintf(self.c.Tr.AbortTitle, mode), - Prompt: fmt.Sprintf(self.c.Tr.AbortPrompt, mode), + Title: utils.ResolvePlaceholderString(self.c.Tr.AbortOperationTitle, placeholders), + Prompt: utils.ResolvePlaceholderString(self.c.Tr.AbortOperationPrompt, placeholders), HandleConfirm: func() error { return self.genericMergeCommand(REBASE_OPTION_ABORT) }, @@ -324,8 +327,10 @@ func (self *MergeAndRebaseHelper) AbortMergeOrRebaseWithConfirm() error { func (self *MergeAndRebaseHelper) PromptToContinueRebase() { self.continueRebasePromptShowing = true self.c.Confirm(types.ConfirmOpts{ - Title: self.c.Tr.Continue, - Prompt: fmt.Sprintf(self.c.Tr.ConflictsResolved, self.c.Git().Status.WorkingTreeState().CommandName()), + Title: self.c.Tr.Continue, + Prompt: utils.ResolvePlaceholderString(self.c.Tr.ContinueAfterConflictsResolved, map[string]string{ + "operation": self.c.Git().Status.WorkingTreeState().OperationName(self.c.Tr), + }), HandleClose: func() error { self.continueRebasePromptShowing = false return nil diff --git a/pkg/gui/controllers/helpers/mode_helper.go b/pkg/gui/controllers/helpers/mode_helper.go index a96164891..efedde3d0 100644 --- a/pkg/gui/controllers/helpers/mode_helper.go +++ b/pkg/gui/controllers/helpers/mode_helper.go @@ -7,6 +7,7 @@ import ( "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/gui/types" + "github.com/jesseduffield/lazygit/pkg/utils" "github.com/samber/lo" ) @@ -140,7 +141,9 @@ func (self *ModeHelper) Statuses() []ModeStatus { ) }, CancelLabel: func() string { - return fmt.Sprintf(self.c.Tr.AbortTitle, self.c.Git().Status.WorkingTreeState().CommandName()) + return utils.ResolvePlaceholderString(self.c.Tr.AbortOperationTitle, map[string]string{ + "operation": self.c.Git().Status.WorkingTreeState().OperationName(self.c.Tr), + }) }, Reset: self.mergeAndRebaseHelper.AbortMergeOrRebaseWithConfirm, }, diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 05a74b0fe..d168db094 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -350,7 +350,7 @@ type TranslationSet struct { FastForwarding string FoundConflictsTitle string ViewConflictsMenuItem string - AbortMenuItem string + AbortOperationMenuItem string PickHunk string PickBothHunks string ViewMergeRebaseOptions string @@ -386,7 +386,7 @@ type TranslationSet struct { InformationTitle string SecondaryTitle string ReflogCommitsTitle string - ConflictsResolved string + ContinueAfterConflictsResolved string Continue string UnstagedFilesAfterConflictsResolved string RebasingTitle string @@ -475,6 +475,10 @@ type TranslationSet struct { LowercaseMergingStatus string LowercaseCherryPickingStatus string LowercaseRevertingStatus string + RebaseOperationName string + MergeOperationName string + CherryPickOperationName string + RevertOperationName string AmendingStatus string CherryPickingStatus string UndoingStatus string @@ -878,8 +882,8 @@ type TranslationSet struct { MustSpecifyOriginError string GitOutput string GitCommandFailed string - AbortTitle string - AbortPrompt string + AbortOperationTitle string + AbortOperationPrompt string OpenLogMenu string OpenLogMenuTooltip string LogMenuTitle string @@ -1571,7 +1575,7 @@ func EnglishTranslationSet() *TranslationSet { FastForwarding: "Fast-forwarding", FoundConflictsTitle: "Conflicts!", ViewConflictsMenuItem: "View conflicts", - AbortMenuItem: "Abort the %s", + AbortOperationMenuItem: "Abort {{.operation}}", ViewMergeRebaseOptions: "View merge/rebase options", ViewMergeRebaseOptionsTooltip: "View options to abort/continue/skip the current merge/rebase.", ViewMergeOptions: "View merge options", @@ -1606,7 +1610,7 @@ func EnglishTranslationSet() *TranslationSet { SecondaryTitle: "Secondary", ReflogCommitsTitle: "Reflog", GlobalTitle: "Global keybindings", - ConflictsResolved: "All merge conflicts resolved. Continue the %s?", + ContinueAfterConflictsResolved: "All merge conflicts resolved. Continue {{.operation}}?", Continue: "Continue", UnstagedFilesAfterConflictsResolved: "Files have been modified since conflicts were resolved. Auto-stage them and continue?", Keybindings: "Keybindings", @@ -1700,6 +1704,10 @@ func EnglishTranslationSet() *TranslationSet { LowercaseMergingStatus: "merging", // lowercase because it shows up in parentheses LowercaseCherryPickingStatus: "cherry-picking", // lowercase because it shows up in parentheses LowercaseRevertingStatus: "reverting", // lowercase because it shows up in parentheses + RebaseOperationName: "the rebase", + MergeOperationName: "the merge", + CherryPickOperationName: "the cherry-pick", + RevertOperationName: "the revert", AmendingStatus: "Amending", CherryPickingStatus: "Cherry-picking", UndoingStatus: "Undoing", @@ -2100,8 +2108,8 @@ func EnglishTranslationSet() *TranslationSet { MustSpecifyOriginError: "Must specify a remote if specifying a branch", GitOutput: "Git output:", GitCommandFailed: "Git command failed. Check command log for details (open with %s)", - AbortTitle: "Abort %s", - AbortPrompt: "Are you sure you want to abort the current %s?", + AbortOperationTitle: "Abort {{.operation}}", + AbortOperationPrompt: "Are you sure you want to abort {{.operation}}?", OpenLogMenu: "View log options", OpenLogMenuTooltip: "View options for commit log e.g. changing sort order, hiding the git graph, showing the whole git graph.", LogMenuTitle: "Commit Log Options",