How do I get the computer's current language in Go?
e.g. en-US for USA or es-es for Spain.
Note: Windows doesn't not rely on LANG environment variable (or LC_* variables: none are defined on my Windows 8)
The locale is stored in HKCU/ControlPanel/International/LocalName (as mentioned in this thread)

So you are better off using a project accessing the registry, like:
registry/registry.goOn *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=
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With