Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internationalise logging of commands #2852

Merged
merged 3 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Moves log related translations into its own Tr.Log. namespace
  • Loading branch information
KarlHeitmann committed Jul 31, 2023
commit b7ba06fa5b01672e7a5012f1f47c4b07918d67d7
8 changes: 4 additions & 4 deletions pkg/commands/git_commands/rebase.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (self *RebaseCommands) MoveCommitDown(commits []*models.Commit, index int)
sha := commits[index].Sha

msg := utils.ResolvePlaceholderString(
self.Tr.Actions.LogMoveCommitDown,
self.Tr.Log.MoveCommitDown,
map[string]string{
"shortSha": utils.ShortSha(sha),
},
Expand All @@ -125,7 +125,7 @@ func (self *RebaseCommands) MoveCommitUp(commits []*models.Commit, index int) er
sha := commits[index].Sha

msg := utils.ResolvePlaceholderString(
self.Tr.Actions.LogMoveCommitUp,
self.Tr.Log.MoveCommitUp,
map[string]string{
"shortSha": utils.ShortSha(sha),
},
Expand Down Expand Up @@ -162,7 +162,7 @@ func (self *RebaseCommands) InteractiveRebase(commits []*models.Commit, index in

func (self *RebaseCommands) EditRebase(branchRef string) error {
msg := utils.ResolvePlaceholderString(
self.Tr.Actions.LogEditRebase,
self.Tr.Log.EditRebase,
map[string]string{
"ref": branchRef,
},
Expand Down Expand Up @@ -431,7 +431,7 @@ func (self *RebaseCommands) CherryPickCommits(commits []*models.Commit) error {
return fmt.Sprintf("%s %s", utils.ShortSha(commit.Sha), commit.Name)
})
msg := utils.ResolvePlaceholderString(
self.Tr.Actions.LogCherryPickCommits,
self.Tr.Log.CherryPickCommits,
map[string]string{
"commitLines": strings.Join(commitLines, "\n"),
},
Expand Down
10 changes: 5 additions & 5 deletions pkg/commands/oscommands/os.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (c *OSCommand) Quote(message string) string {
// AppendLineToFile adds a new line in file
func (c *OSCommand) AppendLineToFile(filename, line string) error {
msg := utils.ResolvePlaceholderString(
c.Tr.Actions.LogAppendingLineToFile,
c.Tr.Log.AppendingLineToFile,
map[string]string{
"line": line,
"filename": filename,
Expand Down Expand Up @@ -163,7 +163,7 @@ func (c *OSCommand) AppendLineToFile(filename, line string) error {
// CreateFileWithContent creates a file with the given content
func (c *OSCommand) CreateFileWithContent(path string, content string) error {
msg := utils.ResolvePlaceholderString(
c.Tr.Actions.LogCreateFileWithContent,
c.Tr.Log.CreateFileWithContent,
map[string]string{
"path": path,
},
Expand All @@ -185,7 +185,7 @@ func (c *OSCommand) CreateFileWithContent(path string, content string) error {
// Remove removes a file or directory at the specified path
func (c *OSCommand) Remove(filename string) error {
msg := utils.ResolvePlaceholderString(
c.Tr.Actions.LogRemove,
c.Tr.Log.Remove,
map[string]string{
"filename": filename,
},
Expand Down Expand Up @@ -287,7 +287,7 @@ func (c *OSCommand) CopyToClipboard(str string) error {
truncated := utils.TruncateWithEllipsis(escaped, 40)

msg := utils.ResolvePlaceholderString(
c.Tr.Actions.LogCopyToClipboard,
c.Tr.Log.CopyToClipboard,
map[string]string{
"str": truncated,
},
Expand All @@ -305,7 +305,7 @@ func (c *OSCommand) CopyToClipboard(str string) error {

func (c *OSCommand) RemoveFile(path string) error {
msg := utils.ResolvePlaceholderString(
c.Tr.Actions.LogRemoveFile,
c.Tr.Log.RemoveFile,
map[string]string{
"path": path,
},
Expand Down
6 changes: 3 additions & 3 deletions pkg/gui/controllers/local_commits_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ func (self *LocalCommitsController) handleMidRebaseCommand(action todo.TodoComma
self.c.LogAction("Update rebase TODO")

msg := utils.ResolvePlaceholderString(
self.c.Tr.Actions.LogHandleMidRebaseCommand,
self.c.Tr.Log.HandleMidRebaseCommand,
map[string]string{
"shortSha": commit.ShortSha(),
"action": action.String(),
Expand Down Expand Up @@ -459,7 +459,7 @@ func (self *LocalCommitsController) moveDown(commit *models.Commit) error {
self.c.LogAction(self.c.Tr.Actions.MoveCommitDown)

msg := utils.ResolvePlaceholderString(
self.c.Tr.Actions.LogMovingCommitDown,
self.c.Tr.Log.MovingCommitDown,
map[string]string{
"shortSha": commit.ShortSha(),
},
Expand Down Expand Up @@ -500,7 +500,7 @@ func (self *LocalCommitsController) moveUp(commit *models.Commit) error {
// to provide a useful log
self.c.LogAction(self.c.Tr.Actions.MoveCommitUp)
msg := utils.ResolvePlaceholderString(
self.c.Tr.Actions.LogMovingCommitUp,
self.c.Tr.Log.MovingCommitUp,
map[string]string{
"shortSha": commit.ShortSha(),
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/gui/controllers/merge_conflicts_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func (self *MergeConflictsController) HandleUndo() error {
}

self.c.LogAction("Restoring file to previous state")
self.c.LogCommand(self.c.Tr.Actions.LogHandleUndo, false)
self.c.LogCommand(self.c.Tr.Log.HandleUndo, false)
if err := os.WriteFile(state.GetPath(), []byte(state.GetContent()), 0o644); err != nil {
return err
}
Expand Down
58 changes: 32 additions & 26 deletions pkg/i18n/english.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ type TranslationSet struct {
MarkedCommitMarker string
Actions Actions
Bisect Bisect
Log Log
}

type Bisect struct {
Expand All @@ -609,6 +610,22 @@ type Bisect struct {
Bisecting string
}

type Log struct {
EditRebase string
MoveCommitUp string
MoveCommitDown string
CherryPickCommits string
HandleUndo string
HandleMidRebaseCommand string
MovingCommitUp string
MovingCommitDown string
RemoveFile string
CopyToClipboard string
Remove string
CreateFileWithContent string
AppendingLineToFile string
}

type Actions struct {
CheckoutCommit string
CheckoutTag string
Expand Down Expand Up @@ -717,19 +734,6 @@ type Actions struct {
BisectMark string
RemoveWorktree string
AddWorktree string
LogEditRebase string
LogMoveCommitUp string
LogMoveCommitDown string
LogCherryPickCommits string
LogHandleUndo string
LogHandleMidRebaseCommand string
LogMovingCommitUp string
LogMovingCommitDown string
LogRemoveFile string
LogCopyToClipboard string
LogRemove string
LogCreateFileWithContent string
LogAppendingLineToFile string
}

const englishIntroPopupMessage = `
Expand Down Expand Up @@ -1451,19 +1455,6 @@ func EnglishTranslationSet() TranslationSet {
BisectMark: "Bisect mark",
RemoveWorktree: "Remove worktree",
AddWorktree: "Add worktree",
LogEditRebase: "Beginning interactive rebase at '{{.ref}}'",
LogMoveCommitUp: "Moving TODO down: '{{.shortSha}}'",
LogMoveCommitDown: "Moving TODO down: '{{.shortSha}}'",
LogCherryPickCommits: "Cherry-picking commits:\n'{{.commitLines}}'",
LogHandleUndo: "Undoing last conflict resolution",
LogHandleMidRebaseCommand: "Updating rebase action of commit {{.shortSha}} to '{{.action}}'",
LogMovingCommitUp: "Moving commit {{.shortSha}} up",
LogMovingCommitDown: "Moving commit {{.shortSha}} down",
LogRemoveFile: "Deleting path '{{.path}}'",
LogCopyToClipboard: "Copying '{{.str}}' to clipboard",
LogRemove: "Removing '{{.filename}}'",
LogCreateFileWithContent: "Creating file '{{.path}}'",
LogAppendingLineToFile: "Appending '{{.line}}' to file '{{.filename}}'",
},
Bisect: Bisect{
Mark: "Mark current commit (%s) as %s",
Expand All @@ -1482,5 +1473,20 @@ func EnglishTranslationSet() TranslationSet {
CompletePromptIndeterminate: "Bisect complete! Some commits were skipped, so any of the following commits may have introduced the change:\n\n%s\n\nDo you want to reset 'git bisect' now?",
Bisecting: "Bisecting",
},
Log: Log{
EditRebase: "Beginning interactive rebase at '{{.ref}}'",
MoveCommitUp: "Moving TODO down: '{{.shortSha}}'",
MoveCommitDown: "Moving TODO down: '{{.shortSha}}'",
CherryPickCommits: "Cherry-picking commits:\n'{{.commitLines}}'",
HandleUndo: "Undoing last conflict resolution",
HandleMidRebaseCommand: "Updating rebase action of commit {{.shortSha}} to '{{.action}}'",
MovingCommitUp: "Moving commit {{.shortSha}} up",
MovingCommitDown: "Moving commit {{.shortSha}} down",
RemoveFile: "Deleting path '{{.path}}'",
CopyToClipboard: "Copying '{{.str}}' to clipboard",
Remove: "Removing '{{.filename}}'",
CreateFileWithContent: "Creating file '{{.path}}'",
AppendingLineToFile: "Appending '{{.line}}' to file '{{.filename}}'",
},
}
}