1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-06 03:53:59 +02:00

Added more translations

This commit is contained in:
Mark Kopenga 2018-08-14 21:06:50 +02:00
parent 38a1a00cf1
commit be3f5846e4
3 changed files with 48 additions and 11 deletions

View File

@ -115,11 +115,19 @@ func (gui *Gui) handleFileRemove(g *gocui.Gui, v *gocui.View) error {
} }
var deleteVerb string var deleteVerb string
if file.Tracked { if file.Tracked {
deleteVerb = "checkout" deleteVerb = gui.Tr.SLocalize("checkout", "checkout")
} else { } else {
deleteVerb = "delete" deleteVerb = gui.Tr.SLocalize("delete", "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 { 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 { if err := gui.GitCommand.RemoveFile(file); err != nil {
panic(err) 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 { func (gui *Gui) handleCommitPress(g *gocui.Gui, filesView *gocui.View) error {
if len(gui.stagedFiles()) == 0 && !gui.State.HasMergeConflicts { 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) commitMessageView := gui.getCommitMessageView(g)
g.Update(func(g *gocui.Gui) error { 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 // their editor rather than via the popup panel
func (gui *Gui) handleCommitEditorPress(g *gocui.Gui, filesView *gocui.View) error { func (gui *Gui) handleCommitEditorPress(g *gocui.Gui, filesView *gocui.View) error {
if len(gui.stagedFiles()) == 0 && !gui.State.HasMergeConflicts { 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") gui.PrepareSubProcess(g, "git", "commit")
return nil return nil
@ -300,7 +308,7 @@ func (gui *Gui) catSelectedFile(g *gocui.Gui) (string, error) {
if err != gui.Errors.ErrNoFiles { if err != gui.Errors.ErrNoFiles {
return "", err 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) cat, err := gui.GitCommand.CatFile(item.Name)
if err != nil { 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 { 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() { go func() {
if err := gui.GitCommand.Pull(); err != nil { if err := gui.GitCommand.Pull(); err != nil {
gui.createErrorPanel(g, err.Error()) 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 { 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() { go func() {
branchName := gui.State.Branches[0].Name branchName := gui.State.Branches[0].Name
if err := gui.GitCommand.Push(branchName); err != nil { 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 return nil
} }
if !file.HasMergeConflicts { 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) gui.switchFocus(g, v, mergeView)
return gui.refreshMergePanel(g) 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 { 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 { if err := gui.GitCommand.ResetHard(); err != nil {
gui.createErrorPanel(g, err.Error()) gui.createErrorPanel(g, err.Error())
} }

View File

@ -92,8 +92,26 @@ func addDutch(i18nObject *i18n.Bundle) {
ID: "CantIgnoreTrackFiles", ID: "CantIgnoreTrackFiles",
Other: "Kan gevolgde bestanden niet negeren", Other: "Kan gevolgde bestanden niet negeren",
}, &i18n.Message{ }, &i18n.Message{
ID: "NoStagedFilesCommit", ID: "NoStagedFilesToCommit",
Other: "Er zijn geen staged bestanden om te commiten", 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)",
}, },
) )
} }

View File

@ -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' // GetLanguage returns the currently selected language, e.g 'en'
func (l *Localizer) GetLanguage() string { func (l *Localizer) GetLanguage() string {
return l.language return l.language