Awesome
go-locale
go-locale
is a Golang lib for cross-platform locale detection.
OS Support
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
POSIX Compatible Systems
- 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
Js
- Lookup env
LANGUAGE
- Lookup env
LC_ALL
Windows
- Lookup env
LANGUAGE
- Lookup env
LC_ALL
- Lookup env
LC_MESSAGES
- Lookup env
LANG
- Windows Registry
macOS X (darwin)
- 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
Usage
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
}
Acknowledgments
Inspired by jibber_jabber