1

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.

1 Answer 1

8

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;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.