fixed package naming and added tr object to file_panel.go

This commit is contained in:
Mark Kopenga
2018-08-14 15:26:25 +02:00
parent 8e22d569a0
commit 73a1682540
4 changed files with 15 additions and 9 deletions

View File

@@ -9,7 +9,7 @@ import (
"github.com/jesseduffield/lazygit/pkg/commands"
"github.com/jesseduffield/lazygit/pkg/config"
"github.com/jesseduffield/lazygit/pkg/gui"
"github.com/mjarkk/lazygit/pkg/i18n"
"github.com/jesseduffield/lazygit/pkg/i18n"
)
// App struct

View File

@@ -14,11 +14,14 @@ import (
"github.com/fatih/color"
"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/commands"
"github.com/jesseduffield/lazygit/pkg/i18n"
)
var tr *i18n.Localizer
var (
errNoFiles = errors.New(lang.SLocalize("NoChangedFiles", "No changed files"))
errNoUsername = errors.New(lang.SLocalize("NoUsernameSetErr", `No username set. Please do: git config --global user.name "Your Name"`))
errNoFiles = errors.New(tr.SLocalize("NoChangedFiles", "No changed files"))
errNoUsername = errors.New(tr.SLocalize("NoUsernameSetErr", `No username set. Please do: git config --global user.name "Your Name"`))
)
func (gui *Gui) stagedFiles() []commands.File {
@@ -86,10 +89,10 @@ func (gui *Gui) handleAddPatch(g *gocui.Gui, v *gocui.View) error {
return err
}
if !file.HasUnstagedChanges {
return gui.createErrorPanel(g, lang.SLocalize("FileHasNoUnstagedChanges", "File has no unstaged changes to add"))
return gui.createErrorPanel(g, tr.SLocalize("FileHasNoUnstagedChanges", "File has no unstaged changes to add"))
}
if !file.Tracked {
return gui.createErrorPanel(g, lang.SLocalize("CannotGitAdd", "Cannot git add --patch untracked files"))
return gui.createErrorPanel(g, tr.SLocalize("CannotGitAdd", "Cannot git add --patch untracked files"))
}
sub, err := gui.GitCommand.AddPatch(file.Name)
if err != nil {
@@ -139,7 +142,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, lang.SLocalize("CantIgnoreTrackFiles", "Cannot ignore tracked files"))
return gui.createErrorPanel(g, tr.SLocalize("CantIgnoreTrackFiles", "Cannot ignore tracked files"))
}
gui.GitCommand.Ignore(file.Name)
return gui.refreshFiles(g)

View File

@@ -19,7 +19,7 @@ import (
"github.com/golang-collections/collections/stack"
"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/commands"
"github.com/mjarkk/lazygit/pkg/i18n"
"github.com/jesseduffield/lazygit/pkg/i18n"
)
// OverlappingEdges determines if panel edges overlap
@@ -59,7 +59,7 @@ type guiState struct {
}
// NewGui builds a new gui handler
func NewGui(log *logrus.Logger, gitCommand *commands.GitCommand, oSCommand *commands.OSCommand, tr *lang.Localizer, version string) (*Gui, error) {
func NewGui(log *logrus.Logger, gitCommand *commands.GitCommand, oSCommand *commands.OSCommand, tr *i18n.Localizer, version string) (*Gui, error) {
initialState := guiState{
Files: make([]commands.File, 0),
PreviousView: "files",

View File

@@ -18,7 +18,10 @@ type Localizer struct {
func NewLocalizer(log *logrus.Logger) (*Localizer, error) {
// detect the user's language
userLang, _ := jibber_jabber.DetectLanguage()
userLang, err := jibber_jabber.DetectLanguage()
if err != nil {
return nil, err
}
log.Info("language: " + userLang)
// create a i18n bundle that can be used to add translations and other things