How do I get the computer's current language in Go?
e.g. en-US for USA or es-es for Spain.
How do I get the computer's current language in Go?
e.g. en-US for USA or es-es for Spain.
On *nix based systems you can simply use os.Getenv("LANG")
, I'm not sure if that applies to windows.
//edit
@JimB mentioned that there are other variables to check too, for more details check gettext
on my system:
➜ locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=