mirror of
https://github.com/cmclark00/retro-imager.git
synced 2025-05-18 16:05:21 +01:00
MacOSX: use other method to detect preferred language
Qt by default consults AppleLanguages property. Use a CFLocaleCopyPreferredLanguages() construct instead. Only look at most preferred language, ignore others. Ref #160
This commit is contained in:
parent
1b7d3fafc0
commit
91cb44d46e
1 changed files with 21 additions and 0 deletions
21
main.cpp
21
main.cpp
|
@ -22,6 +22,9 @@
|
|||
#ifndef QT_NO_WIDGETS
|
||||
#include <QtWidgets/QApplication>
|
||||
#endif
|
||||
#ifdef Q_OS_DARWIN
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#endif
|
||||
|
||||
static QTextStream cerr(stderr);
|
||||
|
||||
|
@ -174,6 +177,24 @@ int main(int argc, char *argv[])
|
|||
|
||||
if (customQm.isEmpty())
|
||||
{
|
||||
#ifdef Q_OS_DARWIN
|
||||
QString langcode = "en_GB";
|
||||
CFArrayRef prefLangs = CFLocaleCopyPreferredLanguages();
|
||||
if (CFArrayGetCount(prefLangs))
|
||||
{
|
||||
char buf[32] = {0};
|
||||
CFStringRef strRef = (CFStringRef) CFArrayGetValueAtIndex(prefLangs, 0);
|
||||
CFStringGetCString(strRef, buf, sizeof(buf), kCFStringEncodingUTF8);
|
||||
CFRelease(strRef);
|
||||
langcode = buf;
|
||||
langcode.replace('-', '_');
|
||||
qDebug() << "OSX most preferred language:" << langcode;
|
||||
}
|
||||
|
||||
CFRelease(prefLangs);
|
||||
QLocale::setDefault(QLocale(langcode));
|
||||
#endif
|
||||
|
||||
if (translator.load(QLocale(), "rpi-imager", "_", QLatin1String(":/i18n")))
|
||||
QCoreApplication::installTranslator(&translator);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue