summaryrefslogtreecommitdiffstats
path: root/pkg/i18n
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2018-08-27 20:57:50 +1000
committerJesse Duffield <jessedduffield@gmail.com>2018-08-27 20:57:50 +1000
commitb4323c029f2a5cc694294195e3f59c5ab4bccea0 (patch)
tree2a194879c325c4872d53caf2f4627da4028b804b /pkg/i18n
parent60422912c8d41628c5ed1b4dd9432694c1be9199 (diff)
parent203ad29349ffa5d935db5d0d320b758a4be7e4b8 (diff)
Merge branch 'master' into feature/add-all
Diffstat (limited to 'pkg/i18n')
-rw-r--r--pkg/i18n/english.go21
-rw-r--r--pkg/i18n/i18n.go10
-rw-r--r--pkg/i18n/i18n_test.go10
3 files changed, 34 insertions, 7 deletions
diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go
index 9c20826ac..5b8624e21 100644
--- a/pkg/i18n/english.go
+++ b/pkg/i18n/english.go
@@ -315,6 +315,27 @@ func addEnglish(i18nObject *i18n.Bundle) error {
}, &i18n.Message{
ID: "ForcePushPrompt",
Other: "Your branch has diverged from the remote branch. Press 'esc' to cancel, or 'enter' to force push.",
+ }, &i18n.Message{
+ ID: "CheckForUpdate",
+ Other: "Check for update",
+ }, &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}}",
+ }, &i18n.Message{
+ ID: "AnonymousReportingTitle",
+ Other: "Help make lazygit better",
+ }, &i18n.Message{
+ ID: "AnonymousReportingPrompt",
+ Other: "Would you like to enable anonymous reporting data to help improve lazygit? (enter/esc)",
},
)
}
diff --git a/pkg/i18n/i18n.go b/pkg/i18n/i18n.go
index 898a13906..1628df707 100644
--- a/pkg/i18n/i18n.go
+++ b/pkg/i18n/i18n.go
@@ -1,9 +1,9 @@
package i18n
import (
- "github.com/sirupsen/logrus"
"github.com/cloudfoundry/jibber_jabber"
"github.com/nicksnyder/go-i18n/v2/i18n"
+ "github.com/sirupsen/logrus"
"golang.org/x/text/language"
)
@@ -14,11 +14,11 @@ type Teml map[string]interface{}
type Localizer struct {
i18nLocalizer *i18n.Localizer
language string
- Log *logrus.Logger
+ Log *logrus.Entry
}
// NewLocalizer creates a new Localizer
-func NewLocalizer(log *logrus.Logger) *Localizer {
+func NewLocalizer(log *logrus.Entry) *Localizer {
userLang := detectLanguage(jibber_jabber.DetectLanguage)
log.Info("language: " + userLang)
@@ -60,7 +60,7 @@ func (l *Localizer) GetLanguage() string {
}
// add translation file(s)
-func addBundles(log *logrus.Logger, i18nBundle *i18n.Bundle) {
+func addBundles(log *logrus.Entry, i18nBundle *i18n.Bundle) {
fs := []func(*i18n.Bundle) error{
addPolish,
addDutch,
@@ -85,7 +85,7 @@ func detectLanguage(langDetector func() (string, error)) string {
}
// setupLocalizer creates a new localizer using given userLang
-func setupLocalizer(log *logrus.Logger, userLang string) *Localizer {
+func setupLocalizer(log *logrus.Entry, userLang string) *Localizer {
// create a i18n bundle that can be used to add translations and other things
i18nBundle := &i18n.Bundle{DefaultLanguage: language.English}
diff --git a/pkg/i18n/i18n_test.go b/pkg/i18n/i18n_test.go
index 5eeddb907..e26b7d1dc 100644
--- a/pkg/i18n/i18n_test.go
+++ b/pkg/i18n/i18n_test.go
@@ -2,6 +2,7 @@ package i18n
import (
"fmt"
+ "io/ioutil"
"testing"
"github.com/nicksnyder/go-i18n/v2/i18n"
@@ -10,8 +11,13 @@ import (
"github.com/stretchr/testify/assert"
)
+func getDummyLog() *logrus.Entry {
+ log := logrus.New()
+ log.Out = ioutil.Discard
+ return log.WithField("test", "test")
+}
func TestNewLocalizer(t *testing.T) {
- assert.NotNil(t, NewLocalizer(logrus.New()))
+ assert.NotNil(t, NewLocalizer(getDummyLog()))
}
func TestDetectLanguage(t *testing.T) {
@@ -76,6 +82,6 @@ func TestLocalizer(t *testing.T) {
}
for _, s := range scenarios {
- s.test(setupLocalizer(logrus.New(), s.userLang))
+ s.test(setupLocalizer(getDummyLog(), s.userLang))
}
}