diff options
author | Christopher Speller <crspeller@gmail.com> | 2016-06-01 11:56:27 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2016-06-01 11:56:27 -0400 |
commit | 786e4dce7d520f79b8cf76939d84678d72941420 (patch) | |
tree | 5bb520880d200cba90c5ada250c63144e18c3333 /vendor/github.com/cloudfoundry/jibber_jabber/jibber_jabber_unix.go | |
parent | b00a60ab71b2bd4640c8608d71805ba9caae97d9 (diff) | |
download | chat-786e4dce7d520f79b8cf76939d84678d72941420.tar.gz chat-786e4dce7d520f79b8cf76939d84678d72941420.tar.bz2 chat-786e4dce7d520f79b8cf76939d84678d72941420.zip |
Revert "PLT-1800 Load server side locale from the config.json" (#3201)
Diffstat (limited to 'vendor/github.com/cloudfoundry/jibber_jabber/jibber_jabber_unix.go')
-rw-r--r-- | vendor/github.com/cloudfoundry/jibber_jabber/jibber_jabber_unix.go | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/vendor/github.com/cloudfoundry/jibber_jabber/jibber_jabber_unix.go b/vendor/github.com/cloudfoundry/jibber_jabber/jibber_jabber_unix.go new file mode 100644 index 000000000..374d76176 --- /dev/null +++ b/vendor/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 +} |