diff options
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/gui/branches_panel.go | 34 | ||||
-rw-r--r-- | pkg/gui/commit_message_panel.go | 3 | ||||
-rw-r--r-- | pkg/gui/commits_panel.go | 36 | ||||
-rw-r--r-- | pkg/gui/confirmation_panel.go | 6 | ||||
-rw-r--r-- | pkg/gui/files_panel.go | 57 | ||||
-rw-r--r-- | pkg/gui/gui.go | 20 | ||||
-rw-r--r-- | pkg/gui/merge_panel.go | 10 | ||||
-rw-r--r-- | pkg/gui/stash_panel.go | 19 | ||||
-rw-r--r-- | pkg/gui/view_helpers.go | 6 | ||||
-rw-r--r-- | pkg/i18n/dutch.go | 9 | ||||
-rw-r--r-- | pkg/i18n/english.go | 11 | ||||
-rw-r--r-- | pkg/i18n/i18n.go | 11 |
12 files changed, 113 insertions, 109 deletions
diff --git a/pkg/gui/branches_panel.go b/pkg/gui/branches_panel.go index b11036d48..2a08eb8b1 100644 --- a/pkg/gui/branches_panel.go +++ b/pkg/gui/branches_panel.go @@ -12,7 +12,7 @@ import ( func (gui *Gui) handleBranchPress(g *gocui.Gui, v *gocui.View) error { index := gui.getItemPosition(v) if index == 0 { - return gui.createErrorPanel(g, gui.Tr.SLocalize("AlreadyCheckedOutBranch", "You have already checked out this branch")) + return gui.createErrorPanel(g, gui.Tr.SLocalize("AlreadyCheckedOutBranch")) } branch := gui.getSelectedBranch(v) if err := gui.GitCommand.Checkout(branch.Name, false); err != nil { @@ -23,8 +23,8 @@ func (gui *Gui) handleBranchPress(g *gocui.Gui, v *gocui.View) error { func (gui *Gui) handleForceCheckout(g *gocui.Gui, v *gocui.View) error { branch := gui.getSelectedBranch(v) - message := gui.Tr.SLocalize("SureForceCheckout", "Are you sure you want force checkout? You will lose all local changes") - title := gui.Tr.SLocalize("ForceCheckoutBranch", "Force Checkout Branch") + message := gui.Tr.SLocalize("SureForceCheckout") + title := gui.Tr.SLocalize("ForceCheckoutBranch") return gui.createConfirmationPanel(g, v, title, message, func(g *gocui.Gui, v *gocui.View) error { if err := gui.GitCommand.Checkout(branch.Name, true); err != nil { gui.createErrorPanel(g, err.Error()) @@ -34,7 +34,7 @@ func (gui *Gui) handleForceCheckout(g *gocui.Gui, v *gocui.View) error { } func (gui *Gui) handleCheckoutByName(g *gocui.Gui, v *gocui.View) error { - gui.createPromptPanel(g, v, gui.Tr.SLocalize("BranchName", "Branch Name")+":", func(g *gocui.Gui, v *gocui.View) error { + gui.createPromptPanel(g, v, gui.Tr.SLocalize("BranchName")+":", func(g *gocui.Gui, v *gocui.View) error { if err := gui.GitCommand.Checkout(gui.trimmedContent(v), false); err != nil { return gui.createErrorPanel(g, err.Error()) } @@ -47,7 +47,6 @@ func (gui *Gui) handleNewBranch(g *gocui.Gui, v *gocui.View) error { branch := gui.State.Branches[0] message := gui.Tr.TemplateLocalize( "NewBranchNameBranchOff", - "New Branch Name (Branch is off of {{.branchName}})", map[string]interface{}{ "branchName": branch.Name, }, @@ -66,16 +65,15 @@ func (gui *Gui) handleDeleteBranch(g *gocui.Gui, v *gocui.View) error { checkedOutBranch := gui.State.Branches[0] selectedBranch := gui.getSelectedBranch(v) if checkedOutBranch.Name == selectedBranch.Name { - return gui.createErrorPanel(g, gui.Tr.SLocalize("CantDeleteCheckOutBranch", "You cannot delete the checked out branch!")) + return gui.createErrorPanel(g, gui.Tr.SLocalize("CantDeleteCheckOutBranch")) } message := gui.Tr.TemplateLocalize( "DeleteBranchMessage", - "Are you sure you want delete the branch {{.selectedBranchName}} ?", map[string]interface{}{ "selectedBranchName": selectedBranch.Name, }, ) - title := gui.Tr.SLocalize("DeleteBranch", "Delete Branch") + title := gui.Tr.SLocalize("DeleteBranch") return gui.createConfirmationPanel(g, v, title, message, func(g *gocui.Gui, v *gocui.View) error { if err := gui.GitCommand.DeleteBranch(selectedBranch.Name); err != nil { return gui.createErrorPanel(g, err.Error()) @@ -89,7 +87,7 @@ func (gui *Gui) handleMerge(g *gocui.Gui, v *gocui.View) error { selectedBranch := gui.getSelectedBranch(v) defer gui.refreshSidePanels(g) if checkedOutBranch.Name == selectedBranch.Name { - return gui.createErrorPanel(g, gui.Tr.SLocalize("CantMergeBranchIntoItself", "You cannot merge a branch into itself")) + return gui.createErrorPanel(g, gui.Tr.SLocalize("CantMergeBranchIntoItself")) } if err := gui.GitCommand.Merge(selectedBranch.Name); err != nil { return gui.createErrorPanel(g, err.Error()) @@ -104,13 +102,13 @@ func (gui *Gui) getSelectedBranch(v *gocui.View) commands.Branch { func (gui *Gui) renderBranchesOptions(g *gocui.Gui) error { return gui.renderOptionsMap(g, map[string]string{ - "space": gui.Tr.SLocalize("checkout", "checkout"), - "f": gui.Tr.SLocalize("forceCheckout", "force checkout"), - "m": gui.Tr.SLocalize("merge", "merge"), - "c": gui.Tr.SLocalize("checkoutByName", "checkout by name"), - "n": gui.Tr.SLocalize("newBranch", "new branch"), - "d": gui.Tr.SLocalize("deleteBranch", "delete branch"), - "← → ↑ ↓": gui.Tr.SLocalize("navigate", "navigate"), + "space": gui.Tr.SLocalize("checkout"), + "f": gui.Tr.SLocalize("forceCheckout"), + "m": gui.Tr.SLocalize("merge"), + "c": gui.Tr.SLocalize("checkoutByName"), + "n": gui.Tr.SLocalize("newBranch"), + "d": gui.Tr.SLocalize("deleteBranch"), + "← → ↑ ↓": gui.Tr.SLocalize("navigate"), }) } @@ -121,13 +119,13 @@ func (gui *Gui) handleBranchSelect(g *gocui.Gui, v *gocui.View) error { } // This really shouldn't happen: there should always be a master branch if len(gui.State.Branches) == 0 { - return gui.renderString(g, "main", gui.Tr.SLocalize("NoBranchesThisRepo", "No branches for this repo")) + return gui.renderString(g, "main", gui.Tr.SLocalize("NoBranchesThisRepo")) } go func() { branch := gui.getSelectedBranch(v) diff, err := gui.GitCommand.GetBranchGraph(branch.Name) if err != nil && strings.HasPrefix(diff, "fatal: ambiguous argument") { - diff = gui.Tr.SLocalize("NoTrackingThisBranch", "There is no tracking for this branch") + diff = gui.Tr.SLocalize("NoTrackingThisBranch") } gui.renderString(g, "main", diff) }() diff --git a/pkg/gui/commit_message_panel.go b/pkg/gui/commit_message_panel.go index 086d4f287..697fbc024 100644 --- a/pkg/gui/commit_message_panel.go +++ b/pkg/gui/commit_message_panel.go @@ -7,7 +7,7 @@ import ( func (gui *Gui) handleCommitConfirm(g *gocui.Gui, v *gocui.View) error { message := gui.trimmedContent(v) if message == "" { - return gui.createErrorPanel(g, gui.Tr.SLocalize("CommitWithoutMessageErr", "You cannot commit without a commit message")) + return gui.createErrorPanel(g, gui.Tr.SLocalize("CommitWithoutMessageErr")) } sub, err := gui.GitCommand.Commit(g, message) if err != nil { @@ -50,7 +50,6 @@ func (gui *Gui) handleNewlineCommitMessage(g *gocui.Gui, v *gocui.View) error { func (gui *Gui) handleCommitFocused(g *gocui.Gui, v *gocui.View) error { message := gui.Tr.TemplateLocalize( "CloseConfirm", - "{{.keyBindClose}}: close, {{.keyBindConfirm}}: confirm", map[string]interface{}{ "keyBindClose": "esc", "keyBindConfirm": "enter", diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go index bc12aff90..417b947a2 100644 --- a/pkg/gui/commits_panel.go +++ b/pkg/gui/commits_panel.go @@ -39,7 +39,7 @@ func (gui *Gui) refreshCommits(g *gocui.Gui) error { } func (gui *Gui) handleResetToCommit(g *gocui.Gui, commitView *gocui.View) error { - return gui.createConfirmationPanel(g, commitView, gui.Tr.SLocalize("ResetToCommit", "Reset To Commit"), gui.Tr.SLocalize("SureResetThisCommit", "Are you sure you want to reset to this commit?"), func(g *gocui.Gui, v *gocui.View) error { + return gui.createConfirmationPanel(g, commitView, gui.Tr.SLocalize("ResetToCommit"), gui.Tr.SLocalize("SureResetThisCommit"), func(g *gocui.Gui, v *gocui.View) error { commit, err := gui.getSelectedCommit(g) if err != nil { panic(err) @@ -60,11 +60,11 @@ func (gui *Gui) handleResetToCommit(g *gocui.Gui, commitView *gocui.View) error func (gui *Gui) renderCommitsOptions(g *gocui.Gui) error { return gui.renderOptionsMap(g, map[string]string{ - "s": gui.Tr.SLocalize("squashDown", "squash down"), - "r": gui.Tr.SLocalize("rename", "rename"), - "g": gui.Tr.SLocalize("resetToThisCommit", "reset to this commit"), - "f": gui.Tr.SLocalize("fixupCommit", "fixup commit"), - "← → ↑ ↓": gui.Tr.SLocalize("navigate", "navigate"), + "s": gui.Tr.SLocalize("squashDown"), + "r": gui.Tr.SLocalize("rename"), + "g": gui.Tr.SLocalize("resetToThisCommit"), + "f": gui.Tr.SLocalize("fixupCommit"), + "← → ↑ ↓": gui.Tr.SLocalize("navigate"), }) } @@ -74,10 +74,10 @@ func (gui *Gui) handleCommitSelect(g *gocui.Gui, v *gocui.View) error { } commit, err := gui.getSelectedCommit(g) if err != nil { - if err != errors.New(gui.Tr.SLocalize("NoCommitsThisBranch", "No commits for this branch")) { + if err != errors.New(gui.Tr.SLocalize("NoCommitsThisBranch")) { return err } - return gui.renderString(g, "main", gui.Tr.SLocalize("NoCommitsThisBranch", "No commits for this branch")) + return gui.renderString(g, "main", gui.Tr.SLocalize("NoCommitsThisBranch")) } commitText := gui.GitCommand.Show(commit.Sha) return gui.renderString(g, "main", commitText) @@ -85,10 +85,10 @@ func (gui *Gui) handleCommitSelect(g *gocui.Gui, v *gocui.View) error { func (gui *Gui) handleCommitSquashDown(g *gocui.Gui, v *gocui.View) error { if gui.getItemPosition(v) != 0 { - return gui.createErrorPanel(g, gui.Tr.SLocalize("OnlySquashTopmostCommit", "Can only squash topmost commit")) + return gui.createErrorPanel(g, gui.Tr.SLocalize("OnlySquashTopmostCommit")) } if len(gui.State.Commits) == 1 { - return gui.createErrorPanel(g, gui.Tr.SLocalize("YouNoCommitsToSquash", "You have no commits to squash with")) + return gui.createErrorPanel(g, gui.Tr.SLocalize("YouNoCommitsToSquash")) } commit, err := gui.getSelectedCommit(g) if err != nil { @@ -116,18 +116,18 @@ func (gui *Gui) anyUnStagedChanges(files []commands.File) bool { func (gui *Gui) handleCommitFixup(g *gocui.Gui, v *gocui.View) error { if len(gui.State.Commits) == 1 { - return gui.createErrorPanel(g, gui.Tr.SLocalize("YouNoCommitsToSquash", "You have no commits to squash with")) + return gui.createErrorPanel(g, gui.Tr.SLocalize("YouNoCommitsToSquash")) } if gui.anyUnStagedChanges(gui.State.Files) { - return gui.createErrorPanel(g, gui.Tr.SLocalize("CantFixupWhileUnstagedChanges", "Can't fixup while there are unstaged changes")) + return gui.createErrorPanel(g, gui.Tr.SLocalize("CantFixupWhileUnstagedChanges")) } branch := gui.State.Branches[0] commit, err := gui.getSelectedCommit(g) if err != nil { return err } - message := gui.Tr.SLocalize("SureFixupThisCommit", "Are you sure you want to fixup this commit? The commit beneath will be squashed up into this one") - gui.createConfirmationPanel(g, v, gui.Tr.SLocalize("Fixup", "Fixup"), message, func(g *gocui.Gui, v *gocui.View) error { + message := gui.Tr.SLocalize("SureFixupThisCommit") + gui.createConfirmationPanel(g, v, gui.Tr.SLocalize("Fixup"), message, func(g *gocui.Gui, v *gocui.View) error { if err := gui.GitCommand.SquashFixupCommit(branch.Name, commit.Sha); err != nil { return gui.createErrorPanel(g, err.Error()) } @@ -141,9 +141,9 @@ func (gui *Gui) handleCommitFixup(g *gocui.Gui, v *gocui.View) error { func (gui *Gui) handleRenameCommit(g *gocui.Gui, v *gocui.View) error { if gui.getItemPosition(v) != 0 { - return gui.createErrorPanel(g, gui.Tr.SLocalize("OnlyRenameTopCommit", "Can only rename topmost commit")) + return gui.createErrorPanel(g, gui.Tr.SLocalize("OnlyRenameTopCommit")) } - gui.createPromptPanel(g, v, gui.Tr.SLocalize("RenameCommit", "Rename Commit"), func(g *gocui.Gui, v *gocui.View) error { + gui.createPromptPanel(g, v, gui.Tr.SLocalize("RenameCommit"), func(g *gocui.Gui, v *gocui.View) error { if err := gui.GitCommand.RenameCommit(v.Buffer()); err != nil { return gui.createErrorPanel(g, err.Error()) } @@ -161,11 +161,11 @@ func (gui *Gui) getSelectedCommit(g *gocui.Gui) (commands.Commit, error) { panic(err) } if len(gui.State.Commits) == 0 { - return commands.Commit{}, errors.New(gui.Tr.SLocalize("NoCommitsThisBranch", "No commits for this branch")) + return commands.Commit{}, errors.New(gui.Tr.SLocalize("NoCommitsThisBranch")) } lineNumber := gui.getItemPosition(v) if lineNumber > len(gui.State.Commits)-1 { - gui.Log.Info(gui.Tr.SLocalize("PotentialErrInGetselectedCommit", "potential error in getSelected Commit (mismatched ui and state)"), gui.State.Commits, lineNumber) + gui.Log.Info(gui.Tr.SLocalize("PotentialErrInGetselectedCommit"), gui.State.Commits, lineNumber) return gui.State.Commits[len(gui.State.Commits)-1], nil } return gui.State.Commits[lineNumber], nil diff --git a/pkg/gui/confirmation_panel.go b/pkg/gui/confirmation_panel.go index 9f76bc1ea..aec190b7f 100644 --- a/pkg/gui/confirmation_panel.go +++ b/pkg/gui/confirmation_panel.go @@ -85,7 +85,6 @@ func (gui *Gui) createConfirmationPanel(g *gocui.Gui, currentView *gocui.View, t if err := gui.closeConfirmationPrompt(g); err != nil { errMessage := gui.Tr.TemplateLocalize( "CantCloseConfirmationPrompt", - "Could not close confirmation prompt: {{.error}}", map[string]interface{}{ "error": err.Error(), }, @@ -126,7 +125,6 @@ func (gui *Gui) handleNewline(g *gocui.Gui, v *gocui.View) error { func (gui *Gui) setKeyBindings(g *gocui.Gui, handleConfirm, handleClose func(*gocui.Gui, *gocui.View) error) error { actions := gui.Tr.TemplateLocalize( "CloseConfirm", - "{{.keyBindClose}}: close, {{.keyBindConfirm}}: confirm", map[string]interface{}{ "keyBindClose": "esc", "keyBindConfirm": "enter", @@ -150,7 +148,7 @@ func (gui *Gui) createErrorPanel(g *gocui.Gui, message string) error { currentView := g.CurrentView() colorFunction := color.New(color.FgRed).SprintFunc() coloredMessage := colorFunction(strings.TrimSpace(message)) - return gui.createConfirmationPanel(g, currentView, gui.Tr.SLocalize("Error", "Error"), coloredMessage, nil, nil) + return gui.createConfirmationPanel(g, currentView, gui.Tr.SLocalize("Error"), coloredMessage, nil, nil) } func (gui *Gui) resizePopupPanel(g *gocui.Gui, v *gocui.View) error { @@ -162,7 +160,7 @@ func (gui *Gui) resizePopupPanel(g *gocui.Gui, v *gocui.View) error { if vx0 == x0 && vy0 == y0 && vx1 == x1 && vy1 == y1 { return nil } - gui.Log.Info(gui.Tr.SLocalize("resizingPopupPanel", "resizing popup panel")) + gui.Log.Info(gui.Tr.SLocalize("resizingPopupPanel")) _, err := g.SetView(v.Name(), x0, y0, x1, y1, 0) return err } diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go index b5296900f..72a7d20b5 100644 --- a/pkg/gui/files_panel.go +++ b/pkg/gui/files_panel.go @@ -80,10 +80,10 @@ func (gui *Gui) handleAddPatch(g *gocui.Gui, v *gocui.View) error { return err } if !file.HasUnstagedChanges { - return gui.createErrorPanel(g, gui.Tr.SLocalize("FileHasNoUnstagedChanges", "File has no unstaged changes to add")) + return gui.createErrorPanel(g, gui.Tr.SLocalize("FileHasNoUnstagedChanges")) } if !file.Tracked { - return gui.createErrorPanel(g, gui.Tr.SLocalize("CannotGitAdd", "Cannot git add --patch untracked files")) + return gui.createErrorPanel(g, gui.Tr.SLocalize("CannotGitAdd")) } sub, err := gui.GitCommand.AddPatch(file.Name) if err != nil { @@ -115,13 +115,12 @@ func (gui *Gui) handleFileRemove(g *gocui.Gui, v *gocui.View) error { } var deleteVerb string if file.Tracked { - deleteVerb = gui.Tr.SLocalize("checkout", "checkout") + deleteVerb = gui.Tr.SLocalize("checkout") } else { - deleteVerb = gui.Tr.SLocalize("delete", "delete") + deleteVerb = gui.Tr.SLocalize("delete") } message := gui.Tr.TemplateLocalize( "SureTo", - "Are you sure you want to {{.deleteVerb}} {{.fileName}} (you will lose your changes)?", map[string]interface{}{ "deleteVerb": deleteVerb, "fileName": file.Name, @@ -141,7 +140,7 @@ func (gui *Gui) handleIgnoreFile(g *gocui.Gui, v *gocui.View) error { return gui.createErrorPanel(g, err.Error()) } if file.Tracked { - return gui.createErrorPanel(g, gui.Tr.SLocalize("CantIgnoreTrackFiles", "Cannot ignore tracked files")) + return gui.createErrorPanel(g, gui.Tr.SLocalize("CantIgnoreTrackFiles")) } gui.GitCommand.Ignore(file.Name) return gui.refreshFiles(g) @@ -149,27 +148,27 @@ func (gui *Gui) handleIgnoreFile(g *gocui.Gui, v *gocui.View) error { func (gui *Gui) renderfilesOptions(g *gocui.Gui, file *commands.File) error { optionsMap := map[string]string{ - "← → ↑ ↓": gui.Tr.SLocalize("navigate", "navigate"), - "S": gui.Tr.SLocalize("stashFiles", "stash files"), - "c": gui.Tr.SLocalize("CommitChanges", "commit changes"), - "o": gui.Tr.SLocalize("open", "open"), - "i": gui.Tr.SLocalize("ignore", "ignore"), - "d": gui.Tr.SLocalize("delete", "delete"), - "space": gui.Tr.SLocalize("toggleStaged", "toggle staged"), - "R": gui.Tr.SLocalize("refresh", "refresh"), - "t": gui.Tr.SLocalize("addPatch", "add patch"), - "e": gui.Tr.SLocalize("edit", "edit"), - "PgUp/PgDn": gui.Tr.SLocalize("scroll", "scroll"), + "← → ↑ ↓": gui.Tr.SLocalize("navigate"), + "S": gui.Tr.SLocalize("stashFiles"), + "c": gui.Tr.SLocalize("CommitChanges"), + "o": gui.Tr.SLocalize("open"), + "i": gui.Tr.SLocalize("ignore"), + "d": gui.Tr.SLocalize("delete"), + "space": gui.Tr.SLocalize("toggleStaged"), + "R": gui.Tr.SLocalize("refresh"), + "t": gui.Tr.SLocalize("addPatch"), + "e": gui.Tr.SLocalize("edit"), + "PgUp/PgDn": gui.Tr.SLocalize("scroll"), } if gui.State.HasMergeConflicts { - optionsMap["a"] = gui.Tr.SLocalize("abortMerge", "abort merge") - optionsMap["m"] = gui.Tr.SLocalize("resolveMergeConflicts", "resolve merge conflicts") + optionsMap["a"] = gui.Tr.SLocalize("abortMerge") + optionsMap["m"] = gui.Tr.SLocalize("resolveMergeConflicts") } if file == nil { return gui.renderOptionsMap(g, optionsMap) } if file.Tracked { - optionsMap["d"] = gui.Tr.SLocalize("checkout", "checkout") + optionsMap["d"] = gui.Tr.SLocalize("checkout") } return gui.renderOptionsMap(g, optionsMap) } @@ -180,7 +179,7 @@ func (gui *Gui) handleFileSelect(g *gocui.Gui, v *gocui.View) error { if err != gui.Errors.ErrNoFiles { return err } - gui.renderString(g, "main", "No changed files") + gui.renderString(g, "main", gui.Tr.SLocalize("NoChangedFiles")) return gui.renderfilesOptions(g, nil) } gui.renderfilesOptions(g, &file) @@ -195,7 +194,7 @@ func (gui *Gui) handleFileSelect(g *gocui.Gui, v *gocui.View) error { func (gui *Gui) handleCommitPress(g *gocui.Gui, filesView *gocui.View) error { if len(gui.stagedFiles()) == 0 && !gui.State.HasMergeConflicts { - return gui.createErrorPanel(g, gui.Tr.SLocalize("NoStagedFilesToCommit", "There are no staged files to commit")) + return gui.createErrorPanel(g, gui.Tr.SLocalize("NoStagedFilesToCommit")) } commitMessageView := gui.getCommitMessageView(g) g.Update(func(g *gocui.Gui) error { @@ -210,7 +209,7 @@ func (gui *Gui) handleCommitPress(g *gocui.Gui, filesView *gocui.View) error { // their editor rather than via the popup panel func (gui *Gui) handleCommitEditorPress(g *gocui.Gui, filesView *gocui.View) error { if len(gui.stagedFiles()) == 0 && !gui.State.HasMergeConflicts { - return gui.createErrorPanel(g, gui.Tr.SLocalize("NoStagedFilesToCommit", "There are no staged files to commit")) + return gui.createErrorPanel(g, gui.Tr.SLocalize("NoStagedFilesToCommit")) } gui.PrepareSubProcess(g, "git", "commit") return nil @@ -308,7 +307,7 @@ func (gui *Gui) catSelectedFile(g *gocui.Gui) (string, error) { if err != gui.Errors.ErrNoFiles { return "", err } - return "", gui.renderString(g, "main", gui.Tr.SLocalize("NoFilesDisplay", "No file to display")) + return "", gui.renderString(g, "main", gui.Tr.SLocalize("NoFilesDisplay")) } cat, err := gui.GitCommand.CatFile(item.Name) if err != nil { @@ -335,7 +334,7 @@ func (gui *Gui) refreshFiles(g *gocui.Gui) error { } func (gui *Gui) pullFiles(g *gocui.Gui, v *gocui.View) error { - gui.createMessagePanel(g, v, "", gui.Tr.SLocalize("PullWait", "Pulling...")) + gui.createMessagePanel(g, v, "", gui.Tr.SLocalize("PullWait")) go func() { if err := gui.GitCommand.Pull(); err != nil { gui.createErrorPanel(g, err.Error()) @@ -350,7 +349,7 @@ func (gui *Gui) pullFiles(g *gocui.Gui, v *gocui.View) error { } func (gui *Gui) pushFiles(g *gocui.Gui, v *gocui.View) error { - gui.createMessagePanel(g, v, "", gui.Tr.SLocalize("PushWait", "Pushing...")) + gui.createMessagePanel(g, v, "", gui.Tr.SLocalize("PushWait")) go func() { branchName := gui.State.Branches[0].Name if err := gui.GitCommand.Push(branchName); err != nil { @@ -377,7 +376,7 @@ func (gui *Gui) handleSwitchToMerge(g *gocui.Gui, v *gocui.View) error { return nil } if !file.HasMergeConflicts { - return gui.createErrorPanel(g, gui.Tr.SLocalize("FileNoMergeCons", "This file has no merge conflicts")) + return gui.createErrorPanel(g, gui.Tr.SLocalize("FileNoMergeCons")) } gui.switchFocus(g, v, mergeView) return gui.refreshMergePanel(g) @@ -387,13 +386,13 @@ func (gui *Gui) handleAbortMerge(g *gocui.Gui, v *gocui.View) error { if err := gui.GitCommand.AbortMerge(); err != nil { return gui.createErrorPanel(g, err.Error()) } - gui.createMessagePanel(g, v, "", "Merge aborted") + gui.createMessagePanel(g, v, "", gui.Tr.SLocalize("MergeAborted")) gui.refreshStatus(g) return gui.refreshFiles(g) } func (gui *Gui) handleResetHard(g *gocui.Gui, v *gocui.View) error { - return gui.createConfirmationPanel(g, v, "Clear file panel", gui.Tr.SLocalize("SureResetHardHead", "Are you sure you want `reset --hard HEAD`? You may lose changes"), func(g *gocui.Gui, v *gocui.View) error { + return gui.createConfirmationPanel(g, v, gui.Tr.SLocalize("ClearFilePanel"), gui.Tr.SLocalize("SureResetHardHead"), func(g *gocui.Gui, v *gocui.View) error { if err := gui.GitCommand.ResetHard(); err != nil { gui.createErrorPanel(g, err.Error()) } diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 5aabca8a8..a6341f755 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -44,8 +44,8 @@ type SentinelErrors struct { // localising things in the code. func (gui *Gui) GenerateSentinelErrors() { gui.Errors = SentinelErrors{ - ErrSubProcess: errors.New(gui.Tr.SLocalize("RunningSubprocess", "running subprocess")), - ErrNoFiles: errors.New(gui.Tr.SLocalize("NoChangedFiles", "No changed files")), + ErrSubProcess: errors.New(gui.Tr.SLocalize("RunningSubprocess")), + ErrNoFiles: errors.New(gui.Tr.SLocalize("NoChangedFiles")), } } @@ -159,7 +159,7 @@ func (gui *Gui) layout(g *gocui.Gui) error { if err != gocui.ErrUnknownView { return err } - v.Title = gui.Tr.SLocalize("NotEnoughSpace", "Not enough space to render panels") + v.Title = gui.Tr.SLocalize("NotEnoughSpace") v.Wrap = true } return nil @@ -178,7 +178,7 @@ func (gui *Gui) layout(g *gocui.Gui) error { if err != gocui.ErrUnknownView { return err } - v.Title = gui.Tr.SLocalize("DiffTitle", "Diff") + v.Title = gui.Tr.SLocalize("DiffTitle") v.Wrap = true v.FgColor = gocui.ColorWhite } @@ -187,7 +187,7 @@ func (gui *Gui) layout(g *gocui.Gui) error { if err != gocui.ErrUnknownView { return err } - v.Title = gui.Tr.SLocalize("StatusTitle", "Status") + v.Title = gui.Tr.SLocalize("StatusTitle") v.FgColor = gocui.ColorWhite } @@ -197,7 +197,7 @@ func (gui *Gui) layout(g *gocui.Gui) error { return err } filesView.Highlight = true - filesView.Title = gui.Tr.SLocalize("FilesTitle", "Files") + filesView.Title = gui.Tr.SLocalize("FilesTitle") v.FgColor = gocui.ColorWhite } @@ -205,7 +205,7 @@ func (gui *Gui) layout(g *gocui.Gui) error { if err != gocui.ErrUnknownView { return err } - v.Title = gui.Tr.SLocalize("BranchesTitle", "Branches") + v.Title = gui.Tr.SLocalize("BranchesTitle") v.FgColor = gocui.ColorWhite } @@ -213,7 +213,7 @@ func (gui *Gui) layout(g *gocui.Gui) error { if err != gocui.ErrUnknownView { return err } - v.Title = gui.Tr.SLocalize("CommitsTitle", "Commits") + v.Title = gui.Tr.SLocalize("CommitsTitle") v.FgColor = gocui.ColorWhite } @@ -221,7 +221,7 @@ func (gui *Gui) layout(g *gocui.Gui) error { if err != gocui.ErrUnknownView { return err } - v.Title = gui.Tr.SLocalize("StashTitle", "Stash") + v.Title = gui.Tr.SLocalize("StashTitle") v.FgColor = gocui.ColorWhite } @@ -240,7 +240,7 @@ func (gui *Gui) layout(g *gocui.Gui) error { return err } g.SetViewOnBottom("commitMessage") - commitMessageView.Title = gui.Tr.SLocalize("CommitMessage", "Commit message") + commitMessageView.Title = gui.Tr.SLocalize("CommitMessage") commitMessageView.FgColor = gocui.ColorWhite commitMessageView.Editable = true } diff --git a/pkg/gui/merge_panel.go b/pkg/gui/merge_panel.go index 213bac739..1efea16da 100644 --- a/pkg/gui/merge_panel.go +++ b/pkg/gui/merge_panel.go @@ -232,11 +232,11 @@ func (gui *Gui) switchToMerging(g *gocui.Gui) error { func (gui *Gui) renderMergeOptions(g *gocui.Gui) error { return gui.renderOptionsMap(g, map[string]string{ - "↑ ↓": gui.Tr.SLocalize("selectHunk", "select hunk"), - "← →": gui.Tr.SLocalize("navigateConflicts", "navigate conflicts"), - "space": gui.Tr.SLocalize("pickHunk", "pick hunk"), - "b": gui.Tr.SLocalize("pickBothHunks", "pick both hunks"), - "z": gui.Tr.SLocalize("undo", "undo"), + "↑ ↓": gui.Tr.SLocalize("selectHunk"), + "← →": gui.Tr.SLocalize("navigateConflicts"), + "space": gui.Tr.SLocalize("pickHunk"), + "b": gui.Tr.SLocalize("pickBothHunks"), + "z": gui.Tr.SLocalize("undo"), }) } diff --git a/pkg/gui/stash_panel.go b/pkg/gui/stash_panel.go index 96d7baba7..bc157f1be 100644 --- a/pkg/gui/stash_panel.go +++ b/pkg/gui/stash_panel.go @@ -33,10 +33,10 @@ func (gui *Gui) getSelectedStashEntry(v *gocui.View) *commands.StashEntry { func (gui *Gui) renderStashOptions(g *gocui.Gui) error { return gui.renderOptionsMap(g, map[string]string{ - "space": gui.Tr.SLocalize("apply", "apply"), - "g": gui.Tr.SLocalize("pop", "pop"), - "d": gui.Tr.SLocalize("drop", "drop"), - "← → ↑ ↓": gui.Tr.SLocalize("navigate", "navigate"), + "space": gui.Tr.SLocalize("apply"), + "g": gui.Tr.SLocalize("pop"), + "d": gui.Tr.SLocalize("drop"), + "← → ↑ ↓": gui.Tr.SLocalize("navigate"), }) } @@ -47,7 +47,7 @@ func (gui *Gui) handleStashEntrySelect(g *gocui.Gui, v *gocui.View) error { go func() { stashEntry := gui.getSelectedStashEntry(v) if stashEntry == nil { - gui.renderString(g, "main", gui.Tr.SLocalize("NoStashEntries", "No stash entries")) + gui.renderString(g, "main", gui.Tr.SLocalize("NoStashEntries")) return } diff, _ := gui.GitCommand.GetStashEntryDiff(stashEntry.Index) @@ -65,8 +65,8 @@ func (gui *Gui) handleStashPop(g *gocui.Gui, v *gocui.View) error { } func (gui *Gui) handleStashDrop(g *gocui.Gui, v *gocui.View) error { - title := gui.Tr.SLocalize("StashDrop", "Stash drop") - message := gui.Tr.SLocalize("SureDropStashEntry", "Are you sure you want to drop this stash entry?") + title := gui.Tr.SLocalize("StashDrop") + message := gui.Tr.SLocalize("SureDropStashEntry") return gui.createConfirmationPanel(g, v, title, message, func(g *gocui.Gui, v *gocui.View) error { return gui.stashDo(g, v, "drop") }, nil) @@ -77,7 +77,6 @@ func (gui *Gui) stashDo(g *gocui.Gui, v *gocui.View, method string) error { if stashEntry == nil { errorMessage := gui.Tr.TemplateLocalize( "NoStashTo", - "No stash to {{.method}}", map[string]interface{}{ "method": method, }, @@ -93,9 +92,9 @@ func (gui *Gui) stashDo(g *gocui.Gui, v *gocui.View, method string) error { func (gui *Gui) handleStashSave(g *gocui.Gui, filesView *gocui.View) error { if len(gui.trackedFiles()) == 0 && len(gui.stagedFiles()) == 0 { - return gui.createErrorPanel(g, gui.Tr.SLocalize("NoTrackedStagedFilesStash", "You have no tracked/staged files to stash")) + return gui.createErrorPanel(g, gui.Tr.SLocalize("NoTrackedStagedFilesStash")) } - gui.createPromptPanel(g, filesView, gui.Tr.SLocalize("StashChanges", "Stash changes"), func(g *gocui.Gui, v *gocui.View) error { + gui.createPromptPanel(g, filesView, gui.Tr.SLocalize("StashChanges"), func(g *gocui.Gui, v *gocui.View) error { if err := gui.GitCommand.StashSave(gui.trimmedContent(v)); err != nil { gui.createErrorPanel(g, err.Error()) } diff --git a/pkg/gui/view_helpers.go b/pkg/gui/view_helpers.go index 48ad73962..0d215a337 100644 --- a/pkg/gui/view_helpers.go +++ b/pkg/gui/view_helpers.go @@ -31,7 +31,6 @@ func (gui *Gui) nextView(g *gocui.Gui, v *gocui.View) error { if i == len(cyclableViews)-1 { message := gui.Tr.TemplateLocalize( "IssntListOfViews", - "{{.name}} is not in the list of views", map[string]interface{}{ "name": v.Name(), }, @@ -61,7 +60,6 @@ func (gui *Gui) previousView(g *gocui.Gui, v *gocui.View) error { if i == len(cyclableViews)-1 { message := gui.Tr.TemplateLocalize( "IssntListOfViews", - "{{.name}} is not in the list of views", map[string]interface{}{ "name": v.Name(), }, @@ -101,7 +99,7 @@ func (gui *Gui) newLineFocused(g *gocui.Gui, v *gocui.View) error { case "stash": return gui.handleStashEntrySelect(g, v) default: - panic(gui.Tr.SLocalize("NoViewMachingNewLineFocusedSwitchStatement", "No view matching newLineFocused switch statement")) + panic(gui.Tr.SLocalize("NoViewMachingNewLineFocusedSwitchStatement")) } } @@ -121,7 +119,6 @@ func (gui *Gui) switchFocus(g *gocui.Gui, oldView, newView *gocui.View) error { oldView.Highlight = false message := gui.Tr.TemplateLocalize( "settingPreviewsViewTo", - "setting previous view to: {{.oldViewName}}", map[string]interface{}{ "oldViewName": oldView.Name(), }, @@ -132,7 +129,6 @@ func (gui *Gui) switchFocus(g *gocui.Gui, oldView, newView *gocui.View) error { newView.Highlight = true message := gui.Tr.TemplateLocalize( "newFocusedViewIs", - "new focused view is {{.newFocusedView}}", map[string]interface{}{ "newFocusedView": newView.Name(), }, diff --git a/pkg/i18n/dutch.go b/pkg/i18n/dutch.go index 9bf542fad..0ba562a22 100644 --- a/pkg/i18n/dutch.go +++ b/pkg/i18n/dutch.go @@ -277,6 +277,15 @@ func addDutch(i18nObject *i18n.Bundle) { }, &i18n.Message{ ID: "CantCloseConfirmationPrompt", Other: "Kon de bevestiging prompt niet sluiten: {{.error}}", + }, &i18n.Message{ + ID: "NoChangedFiles", + Other: "Geen veranderde files", + }, &i18n.Message{ + ID: "ClearFilePanel", + Other: "maak bestandsvenster leeg", + }, &i18n.Message{ + ID: "MergeAborted", + Other: "Merge afgebroken", }, ) } diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index d4c31ae53..6e2af8e22 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -1,7 +1,5 @@ /* -About: this pakcage contains just the contents to gets started with a new translations - Todo list when making a new translation - Copy this file and rename it to the language you want to translate to like someLanguage.go - Change the addEnglish() name to the language you want to translate to like addSomeLanguage() @@ -287,6 +285,15 @@ func addEnglish(i18nObject *i18n.Bundle) { }, &i18n.Message{ ID: "CantCloseConfirmationPrompt", Other: "Could not close confirmation prompt: {{.error}}", + }, &i18n.Message{ + ID: "NoChangedFiles", + Other: "No changed files", + }, &i18n.Message{ + ID: "ClearFilePanel", + Other: "Clear file panel", + }, &i18n.Message{ + ID: "MergeAborted", + Other: "Merge aborted", }, ) } diff --git a/pkg/i18n/i18n.go b/pkg/i18n/i18n.go index 5a09d6d66..2e445391d 100644 --- a/pkg/i18n/i18n.go +++ b/pkg/i18n/i18n.go @@ -51,21 +51,19 @@ func (l *Localizer) Localize(config *i18n.LocalizeConfig) string { // SLocalize (short localize) is for 1 line localizations // ID: The id that is used in the .toml translation files // Other: the default message it needs to return if there is no translation found or the system is english -func (l *Localizer) SLocalize(ID string, Other string) string { +func (l *Localizer) SLocalize(ID string) string { return l.Localize(&i18n.LocalizeConfig{ DefaultMessage: &i18n.Message{ - ID: ID, - Other: Other, + ID: ID, }, }) } // TemplateLocalize allows the Other input to be dynamic -func (l *Localizer) TemplateLocalize(ID string, Other string, TemplateData map[string]interface{}) string { +func (l *Localizer) TemplateLocalize(ID string, TemplateData map[string]interface{}) string { return l.Localize(&i18n.LocalizeConfig{ DefaultMessage: &i18n.Message{ - ID: ID, - Other: Other, + ID: ID, }, TemplateData: TemplateData, }) @@ -79,4 +77,5 @@ func (l *Localizer) GetLanguage() string { // a |