diff options
author | Asaad Mahmood <asaad@spinpunch.com> | 2016-01-20 10:38:13 +0500 |
---|---|---|
committer | Asaad Mahmood <asaad@spinpunch.com> | 2016-01-20 10:38:13 +0500 |
commit | 547ad113c171ba9d2e3d7fc536b3184440b52303 (patch) | |
tree | c7afbb4684d63516e68b47b4a2a8fd8c52d813b2 /Godeps/_workspace/src/github.com/cloudfoundry/jibber_jabber/jibber_jabber_unix.go | |
parent | 2b69cf31aea40d12690e97ce3981e3bd955f501b (diff) | |
parent | 1acd38b7b19521d06d274c42c00ce7072cd92196 (diff) | |
download | chat-547ad113c171ba9d2e3d7fc536b3184440b52303.tar.gz chat-547ad113c171ba9d2e3d7fc536b3184440b52303.tar.bz2 chat-547ad113c171ba9d2e3d7fc536b3184440b52303.zip |
Merge branch 'master' of https://github.com/mattermost/platform into ui-improvements
Diffstat (limited to 'Godeps/_workspace/src/github.com/cloudfoundry/jibber_jabber/jibber_jabber_unix.go')
-rw-r--r-- | Godeps/_workspace/src/github.com/cloudfoundry/jibber_jabber/jibber_jabber_unix.go | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/Godeps/_workspace/src/github.com/cloudfoundry/jibber_jabber/jibber_jabber_unix.go b/Godeps/_workspace/src/github.com/cloudfoundry/jibber_jabber/jibber_jabber_unix.go new file mode 100644 index 000000000..374d76176 --- /dev/null +++ b/Godeps/_workspace/src/github.com/cloudfoundry/jibber_jabber/jibber_jabber_unix.go @@ -0,0 +1,57 @@ +// +build darwin freebsd linux netbsd openbsd + +package jibber_jabber + +import ( + "errors" + "os" + "strings" +) + +func getLangFromEnv() (locale string) { + locale = os.Getenv("LC_ALL") + if locale == "" { + locale = os.Getenv("LANG") + } + return +} + +func getUnixLocale() (unix_locale string, err error) { + unix_locale = getLangFromEnv() + if unix_locale == "" { + err = errors.New(COULD_NOT_DETECT_PACKAGE_ERROR_MESSAGE) + } + + return +} + +func DetectIETF() (locale string, err error) { + unix_locale, err := getUnixLocale() + if err == nil { + language, territory := splitLocale(unix_locale) + locale = language + if territory != "" { + locale = strings.Join([]string{language, territory}, "-") + } + } + + return +} + +func DetectLanguage() (language string, err error) { + unix_locale, err := getUnixLocale() + if err == nil { + language, _ = splitLocale(unix_locale) + } + + return +} + +func DetectTerritory() (territory string, err error) { + unix_locale, err := getUnixLocale() + if err == nil { + _, territory = splitLocale(unix_locale) + } + + return +} |