PDA

View Full Version : Get user UI language



mentalmushroom
16th April 2012, 16:30
Hello, is there any way to find out what is the current user interface language on the system? I am talking of the language used for menus, dialog boxes, help files, and so forth. On Windows it can be set by the current user in the Language tab of the regional and language options portion of Control Panel. The Windows-specific function to find this seems to be GetUserPreferredUILanguages, does Qt provide something similar?

wysota
16th April 2012, 16:33
QLocale::system()

mentalmushroom
16th April 2012, 16:42
Really? I tried it, but it returned a wrong language. The language returned was based on the location, but not on the UI language. Maybe I used a wrong method, I tried QLocale::system().name(). A user may live in Uzbekistan, but have a preferred language set to English, I need a function to return English in that case.

wysota
16th April 2012, 16:49
QLocale::language(), QLocale::languageToString()

mentalmushroom
16th April 2012, 16:55
Nope, I've already tried those things, but it again returns the language for location and doesn't care about the user settings. There is a link that may help to clear up what I mean: http://msdn.microsoft.com/en-us/library/windows/desktop/dd374098(v=vs.85).aspx, but it is only for Windows.

wysota
16th April 2012, 17:22
I understand what you mean but QLocale is the only thing Qt can offer you. You can try one more thing. Construct an empty QLocale object and query that.