diff options
author | Kali Kaneko (leap communications) <kali@leap.se> | 2019-01-12 18:39:45 +0100 |
---|---|---|
committer | Ruben Pollan <meskio@sindominio.net> | 2019-01-17 12:30:32 +0100 |
commit | b1247d2d0d51108c910a73891ff3116e5f032ab1 (patch) | |
tree | e9948964f0bfb1ad2df3bc7bad02aa1f41ccfbd8 /vendor/github.com/jmshal/go-locale/detect_locale_linux.go | |
parent | efcb8312e31b5c2261b1a1e95ace55b322cfcc27 (diff) |
[pkg] all your deps are vendored to us
Diffstat (limited to 'vendor/github.com/jmshal/go-locale/detect_locale_linux.go')
-rw-r--r-- | vendor/github.com/jmshal/go-locale/detect_locale_linux.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/vendor/github.com/jmshal/go-locale/detect_locale_linux.go b/vendor/github.com/jmshal/go-locale/detect_locale_linux.go new file mode 100644 index 0000000..df0c33d --- /dev/null +++ b/vendor/github.com/jmshal/go-locale/detect_locale_linux.go @@ -0,0 +1,31 @@ +package go_locale + +import ( + "strings" + "errors" +) + +func DetectLocale() (string, error) { + out, err := getCommandOutput("locale") + if err != nil { + return "", err + } + + lines := strings.Split(out, "\n") + for _, line := range lines { + if line != "" { + parts := strings.Split(line, "=") + value := strings.Trim(parts[1], `"`) + + if value != "C" && value != "" { + encodingIndex := strings.Index(value, ".") + if encodingIndex != -1 { + value = value[0:encodingIndex] + } + return value, nil + } + } + } + + return "", errors.New("unable to locale locale") +} |