diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2018-08-26 15:46:18 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2018-08-26 16:53:31 +1000 |
commit | 540edc0c35e97393d9a01c927f7ac962bcbf6d37 (patch) | |
tree | f9f93b1905828f0c665fc25819400e16f4cbc27e /pkg/i18n | |
parent | 93ab892bdd1226f9a519a938c8b28590e71e54f3 (diff) |
anonymous reporting data
Diffstat (limited to 'pkg/i18n')
-rw-r--r-- | pkg/i18n/english.go | 6 | ||||
-rw-r--r-- | pkg/i18n/i18n.go | 10 | ||||
-rw-r--r-- | pkg/i18n/i18n_test.go | 10 |
3 files changed, 19 insertions, 7 deletions
diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 38fbac4cb..cd3438409 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -312,6 +312,12 @@ 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: "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)) } } |