summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2018-08-27 20:23:47 +1000
committerJesse Duffield <jessedduffield@gmail.com>2018-08-27 20:23:47 +1000
commit25c60b185491f6690d42527a4844bc41a09266a7 (patch)
tree96fdc6d66ebaa0022757bd0058c221235600af02
parent38557f131dc1abef3dcc42dfbaa94bf410f209ca (diff)
localize update errors
-rw-r--r--pkg/app/app.go2
-rw-r--r--pkg/i18n/english.go9
-rw-r--r--pkg/updates/updates.go17
3 files changed, 23 insertions, 5 deletions
diff --git a/pkg/app/app.go b/pkg/app/app.go
index 6685f5f9e..f8cc01b6c 100644
--- a/pkg/app/app.go
+++ b/pkg/app/app.go
@@ -56,7 +56,7 @@ func NewApp(config config.AppConfigurer) (*App, error) {
if err != nil {
return app, err
}
- app.Updater, err = updates.NewUpdater(app.Log, config, app.OSCommand)
+ app.Updater, err = updates.NewUpdater(app.Log, config, app.OSCommand, app.Tr)
if err != nil {
return app, err
}
diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go
index bc51f4136..c7214053e 100644
--- a/pkg/i18n/english.go
+++ b/pkg/i18n/english.go
@@ -318,6 +318,15 @@ func addEnglish(i18nObject *i18n.Bundle) error {
}, &i18n.Message{
ID: "CheckingForUpdates",
Other: "Checking for updates...",
+ }, &i18n.Message{
+ ID: "OnLatestVersionErr",
+ Other: "You already have the latest version",
+ }, &i18n.Message{
+ ID: "MajorVersionErr",
+ Other: "New version has non-backwards compatible changes.",
+ }, &i18n.Message{
+ ID: "CouldNotFindBinaryErr",
+ Other: "Could not find any binary at {{.url}}",
},
)
}
diff --git a/pkg/updates/updates.go b/pkg/updates/updates.go
index ad9259cc6..7de71f7a6 100644
--- a/pkg/updates/updates.go
+++ b/pkg/updates/updates.go
@@ -18,6 +18,7 @@ import (
getter "github.com/jesseduffield/go-getter"
"github.com/jesseduffield/lazygit/pkg/commands"
"github.com/jesseduffield/lazygit/pkg/config"
+ "github.com/jesseduffield/lazygit/pkg/i18n"
"github.com/sirupsen/logrus"
)
@@ -26,6 +27,7 @@ type Updater struct {
Log *logrus.Entry
Config config.AppConfigurer
OSCommand *commands.OSCommand
+ Tr *i18n.Localizer
}
// Updater implements the check and update methods
@@ -39,13 +41,14 @@ var (
)
// NewUpdater creates a new updater
-func NewUpdater(log *logrus.Logger, config config.AppConfigurer, osCommand *commands.OSCommand) (*Updater, error) {
+func NewUpdater(log *logrus.Logger, config config.AppConfigurer, osCommand *commands.OSCommand, tr *i18n.Localizer) (*Updater, error) {
contextLogger := log.WithField("context", "updates")
updater := &Updater{
Log: contextLogger,
Config: config,
OSCommand: osCommand,
+ Tr: tr,
}
return updater, nil
}
@@ -102,11 +105,11 @@ func (u *Updater) checkForNewUpdate() (string, error) {
u.Log.Info("New version is " + newVersion)
if newVersion == u.Config.GetVersion() {
- return "", errors.New("You already have the latest version")
+ return "", errors.New(u.Tr.SLocalize("OnLatestVersionErr"))
}
if u.majorVersionDiffers(u.Config.GetVersion(), newVersion) {
- return "", errors.New("New version has non-backwards compatible changes.")
+ return "", errors.New(u.Tr.SLocalize("MajorVersionErr"))
}
rawUrl, err := u.getBinaryUrl(newVersion)
@@ -115,7 +118,13 @@ func (u *Updater) checkForNewUpdate() (string, error) {
}
u.Log.Info("Checking for resource at url " + rawUrl)
if !u.verifyResourceFound(rawUrl) {
- return "", errors.New("Could not find any binary at " + rawUrl)
+ errMessage := u.Tr.TemplateLocalize(
+ "CouldNotFindBinaryErr",
+ i18n.Teml{
+ "url": rawUrl,
+ },
+ )
+ return "", errors.New(errMessage)
}
u.Log.Info("Verified resource is available, ready to update")