go-locale
is a Golang lib for cross-platform locale detection.
Support all OS that Golang supported, except android
:
- aix: IBM AIX operating system
- android (have no idea on this)
- darwin: Drawin, Mac OS X
- dragonfly: DragonFly BSD
- freebsd: FreeBSD
- hurd: GNU Hurd
- illumos
- js: JavaScript runtime, WebAssembly
- Linux: Ubuntu, CentOS, RHEL, Archlinux...
- nacl: Native Client
- netbsd: NetBSD
- openbsd: OpenBSD
- plan9: Plan 9 from Bell Labs
- solaris: Solaris
- windows: Windows
- zos: z/OS
- Lookup env
LANGUAGE
- Lookup env
LC_ALL
- Lookup env
LC_MESSAGES
- Lookup env
LANG
- Read file
$XDG_CONFIG_HOME/locale.conf
- Read file
$HOME/.config/locale.conf
- Read file
/etc/locale.conf
- Lookup env
LANGUAGE
- Lookup env
LC_ALL
- Lookup env
LANGUAGE
- Lookup env
LC_ALL
- Lookup env
LC_MESSAGES
- Lookup env
LANG
- Windows Registry
- Lookup env
LANGUAGE
- Lookup env
LC_ALL
- Lookup env
LC_MESSAGES
- Lookup env
LANG
- macOS X User Defaults System
- Lookup user AppleLocale
- Lookup user AppleLanguages
- Lookup global AppleLocale
- Lookup global AppleLanguages
import (
"github.com/Xuanwo/go-locale"
)
func main() {
tag, err := locale.Detect()
if err != nil {
log.Fatal(err)
}
// Have fun with language.Tag!
tags, err := locale.DetectAll()
if err != nil {
log.Fatal(err)
}
// Get all available tags
}
Inspired by jibber_jabber