I'll solve myself:
From the QSettings doc:
On Mac OS X, allKeys() will return some extra keys for global settings that apply to all applications. These keys can be read using value() but cannot be changed, only shadowed. Calling setFallbacksEnabled(false) will hide these global settings.
QSettings::allKeys() lists, among many others, "AppleLanguages" - which I have come across before, see above.
So the solution is simple:
QSettings settings;
//no user specific settings needed QVariant osxLanguageSettings
= settings.
value("AppleLanguages");
//list of all languages (as opposed to regions) as set in the system preferences QStringList displayLanguages
= osxLanguageSettings.
toStringList();
//e.g. {"en", "de", "fr", "it"} on my system QString preferredLanguage
= displayLanguages.
first();
//first in list is the preferred one qDebug() << "preferred language is:" << preferredLanguage; //"en"
//however...
qDebug
() <<
"system locale is:" <<
QLocale::system();
//e.g. "nb_NO" in case of 'Norwegian Bokmål' region/locale
QSettings settings; //no user specific settings needed
QVariant osxLanguageSettings = settings.value("AppleLanguages"); //list of all languages (as opposed to regions) as set in the system preferences
QStringList displayLanguages = osxLanguageSettings.toStringList(); //e.g. {"en", "de", "fr", "it"} on my system
QString preferredLanguage = displayLanguages.first(); //first in list is the preferred one
qDebug() << "preferred language is:" << preferredLanguage; //"en"
//however...
qDebug() << "system locale is:" << QLocale::system(); //e.g. "nb_NO" in case of 'Norwegian Bokmål' region/locale
To copy to clipboard, switch view to plain text mode
You can iterate the list for a fallback.
Hth.
Bookmarks