How can I get the system language in C/C++? Like en_US or en_GB.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
On a POSIX system, it looks like setlocale(LC_CTYPE, NULL); would return the current locale.
回答2:
Generally you don't -- rather, you (usually) want to just conform to what it asks for using the nameless locale (i.e., std::locale("");
will give you the locale of the user's choosing).
回答3:
Dup of Find out the language windows was installed as
In summary - "the Win32 function you want is GetSystemDefaultUILanguage()" (assuming Windows of course)
回答4:
There isn't necessarily one system language; individual "facets" of the locale can be configured separately. It's all done with environment variables; http://www.manpagez.com/man/1/locale/ has a partial list of variables and their meanings.