Skip to content

Commit

Permalink
i18n: Set language to en-US if detect failed instead of exit 1 (#291)
Browse files Browse the repository at this point in the history
  • Loading branch information
Prnyself authored Jun 3, 2020
1 parent 9a3893d commit beaf75e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ go 1.12
require (
bou.ke/monkey v1.0.2
github.com/AlecAivazis/survey/v2 v2.0.7
github.com/Xuanwo/go-locale v0.0.0-20191213075353-2b399f1605a6
github.com/Xuanwo/go-locale v0.3.0
github.com/Xuanwo/navvy v0.0.0-20191010141320-12f3cfcb6a27
github.com/Xuanwo/storage v1.2.1-0.20200527102749-4370d2c8933b
github.com/c2h5oh/datasize v0.0.0-20171227191756-4eba002a5eae
github.com/go-openapi/strfmt v0.19.0 // indirect
github.com/google/uuid v1.1.1
github.com/jedib0t/go-pretty v4.3.0+incompatible
github.com/mattn/go-runewidth v0.0.4 // indirect
github.com/qingstor/noah v0.0.0-20200528101848-afce1ef8f885
github.com/qingstor/noah v0.0.0-20200602031723-83ba70345eb9
github.com/sirupsen/logrus v1.6.0
github.com/spf13/cobra v0.0.7
github.com/spf13/viper v1.6.3
Expand Down
10 changes: 4 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
bou.ke/monkey v1.0.1 h1:zEMLInw9xvNakzUUPjfS4Ds6jYPqCFx3m7bRmG5NH2U=
bou.ke/monkey v1.0.1/go.mod h1:FgHuK96Rv2Nlf+0u1OOVDpCMdsWyOFmeeketDHE7LIg=
bou.ke/monkey v1.0.2 h1:kWcnsrCNUatbxncxR/ThdYqbytgOIArtYWqcQLQzKLI=
bou.ke/monkey v1.0.2/go.mod h1:OqickVX3tNx6t33n1xvtTtu85YN5s6cKwVug+oHMaIA=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
Expand Down Expand Up @@ -55,8 +53,8 @@ github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAE
github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM=
github.com/VividCortex/ewma v1.1.1 h1:MnEK4VOv6n0RSY4vtRe3h11qjxL3+t0B8yOL8iMXdcM=
github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmxzcbUokwA=
github.com/Xuanwo/go-locale v0.0.0-20191213075353-2b399f1605a6 h1:/u0mUEmkbizUMKJCfXDR+BE7Nxh37N4TFGB0/Ds+vqA=
github.com/Xuanwo/go-locale v0.0.0-20191213075353-2b399f1605a6/go.mod h1:vUBKuDJqYGwnCvPqrkin4mqvUXhA7wO+OO5XWMDOYF4=
github.com/Xuanwo/go-locale v0.3.0 h1:clHbJN2GT4xGZ8BqcIJr42Yfoe06iYzI36LIxBnQ6DY=
github.com/Xuanwo/go-locale v0.3.0/go.mod h1:6qbT9M726OJgyiGZro2YwPmx63wQzlH+VvtjJWQoftw=
github.com/Xuanwo/navvy v0.0.0-20191010141320-12f3cfcb6a27 h1:zSUdlUFOVurqOOXYregowl3LDoHimf8pjWeimSkzokM=
github.com/Xuanwo/navvy v0.0.0-20191010141320-12f3cfcb6a27/go.mod h1:FfMsXg0w9OrzdLvhDHGzdBx35cw1qTpKLcGNC8RtgQA=
github.com/Xuanwo/storage v1.2.1-0.20200527102749-4370d2c8933b h1:uJtJc7gBpU8ujgaPHHmw6juC3I5Cu0jQPd9VB7mIlcM=
Expand Down Expand Up @@ -254,8 +252,8 @@ github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/qingstor/noah v0.0.0-20200528101848-afce1ef8f885 h1:ISHDuQEWDrriaizjVfRQjwyUdlDnvIEr3k+szdXjNQc=
github.com/qingstor/noah v0.0.0-20200528101848-afce1ef8f885/go.mod h1:dC+Sss4QyqObv7daY7xC6quxqOJhbdbo3h4AYgOEHN4=
github.com/qingstor/noah v0.0.0-20200602031723-83ba70345eb9 h1:8ux3SmeHIerYz0HpIsSBVBq1irtvof8TaWVUjWM0Qr8=
github.com/qingstor/noah v0.0.0-20200602031723-83ba70345eb9/go.mod h1:dC+Sss4QyqObv7daY7xC6quxqOJhbdbo3h4AYgOEHN4=
github.com/qingstor/qingstor-sdk-go/v4 v4.0.0 h1:9j+4MhIxhZr3bHkYhVfAVjvsvtwI0I6gB5Xsx6XMPNs=
github.com/qingstor/qingstor-sdk-go/v4 v4.0.0/go.mod h1:WM7DpsJxaOLCAX1K7R4KOBvzEpM4gfAjyN45IIV6rZ0=
github.com/qiniu/api.v7/v7 v7.5.0/go.mod h1:VE5oC5rkE1xul0u1S2N0b2Uxq9/6hZzhyqjgK25XDcM=
Expand Down
5 changes: 3 additions & 2 deletions pkg/i18n/i18n.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package i18n

import (
"io"
"os"

"github.com/Xuanwo/go-locale"
log "github.com/sirupsen/logrus"
"golang.org/x/text/language"
"golang.org/x/text/message"
)
Expand Down Expand Up @@ -91,7 +91,8 @@ func Sprint(a ...interface{}) string {
func init() {
tag, err := locale.Detect()
if err != nil {
os.Exit(1)
log.Errorf("locale detect failed: [%v], use en_us instead", err)
tag = language.AmericanEnglish
}
Init(tag)
p = message.NewPrinter(tag)
Expand Down

0 comments on commit beaf75e

Please sign in to comment.