Lev M.
Lev M.

Reputation: 139

Preferred user language in C++ program

What is the proper way in standard C++ to query the preferred user language, e.g. en_US?

The Win32 API includes a beautifully named function GetUserDefaultUILanguage that does exactly this, but I want to be cross-platform and do it with facilities provides by the standard C++ library.

Upvotes: 1

Views: 284

Answers (1)

Drew Dormann
Drew Dormann

Reputation: 63775

std::locale is a very similar standard library construct, where constructing it with an empty string produces what's believed to be the user's preferred locale.

std::locale("").name(), for example, might produce en_US.UTF8

Upvotes: 2

Related Questions