diff options
author | Mark Kopenga <mkopenga@gmail.com> | 2018-08-14 21:06:50 +0200 |
---|---|---|
committer | Mark Kopenga <mkopenga@gmail.com> | 2018-08-14 21:06:50 +0200 |
commit | be3f5846e48c6f775496fd9f0a6827ae1356bba7 (patch) | |
tree | 9298e7c53837c906bf589b411e920e289440da06 | |
parent | 38a1a00cf158a9c1fd9c70ec44f932491ab1f26f (diff) |
Added more translations
-rw-r--r-- | pkg/gui/files_panel.go | 30 | ||||
-rw-r--r-- | pkg/i18n/dutch.go | 20 | ||||
-rw-r--r-- | pkg/i18n/i18n.go | 11 |
3 files changed, 49 insertions, 12 deletions
diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go index f65dde439..b5296900f 100644 --- a/pkg/gui/files_panel.go +++ b/pkg/gui/files_panel.go @@ -115,11 +115,19 @@ func (gui *Gui) handleFileRemove(g *gocui.Gui, v *gocui.View) error { } var deleteVerb string if file.Tracked { - deleteVerb = "checkout" + deleteVerb = gui.Tr.SLocalize("checkout", "checkout") } else { - deleteVerb = "delete" - } - return gui.createConfirmationPanel(g, v, strings.Title(deleteVerb)+" file", "Are you sure you want to "+deleteVerb+" "+file.Name+" (you will lose your changes)?", func(g *gocui.Gui, v *gocui.View) error { + deleteVerb = gui.Tr.SLocalize("delete", "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, + }, + ) + return gui.createConfirmationPanel(g, v, strings.Title(deleteVerb)+" file", message, func(g *gocui.Gui, v *gocui.View) error { if err := gui.GitCommand.RemoveFile(file); err != nil { panic(err) } @@ -187,7 +195,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("NoStagedFilesCommit", "There are no staged files to commit")) + return gui.createErrorPanel(g, gui.Tr.SLocalize("NoStagedFilesToCommit", "There are no staged files to commit")) } commitMessageView := gui.getCommitMessageView(g) g.Update(func(g *gocui.Gui) error { @@ -202,7 +210,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, "There are no staged files to commit") + return gui.createErrorPanel(g, gui.Tr.SLocalize("NoStagedFilesToCommit", "There are no staged files to commit")) } gui.PrepareSubProcess(g, "git", "commit") return nil @@ -300,7 +308,7 @@ func (gui *Gui) catSelectedFile(g *gocui.Gui) (string, error) { if err != gui.Errors.ErrNoFiles { return "", err } - return "", gui.renderString(g, "main", "No file to display") + return "", gui.renderString(g, "main", gui.Tr.SLocalize("NoFilesDisplay", "No file to display")) } cat, err := gui.GitCommand.CatFile(item.Name) if err != nil { @@ -327,7 +335,7 @@ func (gui *Gui) refreshFiles(g *gocui.Gui) error { } func (gui *Gui) pullFiles(g *gocui.Gui, v *gocui.View) error { - gui.createMessagePanel(g, v, "", "Pulling...") + gui.createMessagePanel(g, v, "", gui.Tr.SLocalize("PullWait", "Pulling...")) go func() { if err := gui.GitCommand.Pull(); err != nil { gui.createErrorPanel(g, err.Error()) @@ -342,7 +350,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, "", "Pushing...") + gui.createMessagePanel(g, v, "", gui.Tr.SLocalize("PushWait", "Pushing...")) go func() { branchName := gui.State.Branches[0].Name if err := gui.GitCommand.Push(branchName); err != nil { @@ -369,7 +377,7 @@ func (gui *Gui) handleSwitchToMerge(g *gocui.Gui, v *gocui.View) error { return nil } if !file.HasMergeConflicts { - return gui.createErrorPanel(g, "This file has no merge conflicts") + return gui.createErrorPanel(g, gui.Tr.SLocalize("FileNoMergeCons", "This file has no merge conflicts")) } gui.switchFocus(g, v, mergeView) return gui.refreshMergePanel(g) @@ -385,7 +393,7 @@ func (gui *Gui) handleAbortMerge(g *gocui.Gui, v *gocui.View) error { } func (gui *Gui) handleResetHard(g *gocui.Gui, v *gocui.View) error { - return gui.createConfirmationPanel(g, v, "Clear file panel", "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, "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 { if err := gui.GitCommand.ResetHard(); err != nil { gui.createErrorPanel(g, err.Error()) } diff --git a/pkg/i18n/dutch.go b/pkg/i18n/dutch.go index e6ef4ff7e..1ad7b3b26 100644 --- a/pkg/i18n/dutch.go +++ b/pkg/i18n/dutch.go @@ -92,8 +92,26 @@ func addDutch(i18nObject *i18n.Bundle) { ID: "CantIgnoreTrackFiles", Other: "Kan gevolgde bestanden niet negeren", }, &i18n.Message{ - ID: "NoStagedFilesCommit", + ID: "NoStagedFilesToCommit", Other: "Er zijn geen staged bestanden om te commiten", + }, &i18n.Message{ + ID: "NoFilesDisplay", + Other: "Geen bestanden om te laten zien", + }, &i18n.Message{ + ID: "PullWait", + Other: "Pulling...", + }, &i18n.Message{ + ID: "PushWait", + Other: "Pushing...", + }, &i18n.Message{ + ID: "FileNoMergeCons", + Other: "Dit bestand heeft geen merge conflicten", + }, &i18n.Message{ + ID: "SureResetHardHead", + Other: "Weet je het zeker dat je `reset --hard HEAD` wil uitvoeren? het kan dat je hierdoor bestanden verliest", + }, &i18n.Message{ + ID: "SureTo", + Other: "Weet je het zeker dat je {{.fileName}} wilt {{.deleteVerb}} (je veranderingen zullen worden verwijdert)", }, ) } diff --git a/pkg/i18n/i18n.go b/pkg/i18n/i18n.go index f54cb9d80..5a09d6d66 100644 --- a/pkg/i18n/i18n.go +++ b/pkg/i18n/i18n.go @@ -60,6 +60,17 @@ func (l *Localizer) SLocalize(ID string, Other string) string { }) } +// TemplateLocalize allows the Other input to be dynamic +func (l *Localizer) TemplateLocalize(ID string, Other string, TemplateData map[string]interface{}) string { + return l.Localize(&i18n.LocalizeConfig{ + DefaultMessage: &i18n.Message{ + ID: ID, + Other: Other, + }, + TemplateData: TemplateData, + }) +} + // GetLanguage returns the currently selected language, e.g 'en' func (l *Localizer) GetLanguage() string { return l.language |