Reputation: 1411
I am newbie to mfc, and I got struck over how to get the current operating system language (Ex: If it is English operating system I must get it as English and locale can be different. For English OS locale can be Japanese vice versa).
Current locale I am getting it through GetSystemDefaultLangID
and the only thing I was left with is I need to get the current operating system language.
Can anyone kindly help me to resolve this issue.
Upvotes: 1
Views: 3026
Reputation: 31599
Perhaps you need GetUserDefaultUILanguage
. The system's settings and user settings may not be the same.
User Interface Language Management
int wmain()
{
wcout << "GetUserDefaultUILanguage: " << GetUserDefaultUILanguage() << "\n";
wcout << "GetSystemDefaultUILanguage: " << GetSystemDefaultUILanguage() << "\n";
wcout << "\n";
wcout << "GetUserDefaultLangID: " << GetUserDefaultLangID() << "\n";
wcout << "GetSystemDefaultLangID: " << GetSystemDefaultLangID() << "\n";
wcout << "\n";
wcout << "GetUserDefaultLCID: " << GetUserDefaultLCID() << "\n";
wcout << "GetSystemDefaultLCID: " << GetSystemDefaultLCID() << "\n";
wcout << "\n";
wchar_t buf[100];
LCID lcid = GetUserDefaultLCID();
cout << "GetUserDefaultLCID: " << "\n";
if (GetLocaleInfo(lcid, LOCALE_ILANGUAGE, buf, 100)) wcout << buf << "\n";
if (GetLocaleInfo(lcid, LOCALE_SENGLANGUAGE, buf, 100)) wcout << buf << "\n";
if (GetLocaleInfo(lcid, LOCALE_SISO639LANGNAME, buf, 100)) wcout << buf << "\n";
return 0;
}
Upvotes: 8