Copy QT and OSCAR translation files into Mac .app bundle.

They are stored in two separate locations (Contents/translations
for QT and Contents/Resources/translations) because
QLibraryInfo::location(QLibraryInfo::TranslationsPath) returns
the former only after macdeployqt has run, and returns Qt's
installed location prior to that.

And Contents/Resources/translations is the better location,
so we use it where we can.
This commit is contained in:
sawinglogz 2019-08-15 23:07:54 -04:00
parent 84b900ca90
commit ad09695531
2 changed files with 17 additions and 4 deletions

View File

@ -165,7 +165,18 @@ macx {
HelpFiles.path = Contents/Resources/Help
QMAKE_BUNDLE_DATA += HelpFiles
}
QtTransFiles.files = $$files($$[QT_INSTALL_TRANSLATIONS]/qt*.qm)
QtTransFiles.path = Contents/translations
QMAKE_BUNDLE_DATA += QtTransFiles
TransFiles.files = $$files($$PWD/translations/*.qm)
TransFiles.path = Contents/Resources/translations
QMAKE_BUNDLE_DATA += TransFiles
HtmlFiles.files = $${HTML_FILES}
HtmlFiles.path = Contents/Resources/html
QMAKE_BUNDLE_DATA += HtmlFiles
} else {
!contains(DEFINES, helpless) {
HELPDIR = $$OUT_PWD/Help

View File

@ -1,5 +1,6 @@
/* Multilingual Support files
/* Multilingual Support files
*
* Copyright (c) 2019 The OSCAR Team
* Copyright (c) 2011-2018 Mark Watkins <mark@jedimark.net>
*
* This file is subject to the terms and conditions of the GNU General Public
@ -176,11 +177,12 @@ void initTranslations()
QString qtLang = language.left(2);
if ( qtLang.compare("zh") == 0 )
qtLang.append("_CN");
qDebug() << "Loading" << langname << "QT translation" << "qt_" + qtLang + ".qm" << "from" << qtLangPath.toLocal8Bit().data();
QString qtLangFile = "qt_" + qtLang + ".qm";
qDebug() << "Loading" << langname << "QT translation" << qtLangFile.toLocal8Bit().data() << "from" << qtLangPath.toLocal8Bit().data();
QTranslator * qtranslator = new QTranslator();
if (!langfile.isEmpty() && !qtranslator->load("qt_" + qtLang + ".qm", qtLangPath)) {
qWarning() << "Could not load QT translation" << langfile << "reverting to english :(";
if (!qtLangFile.isEmpty() && !qtranslator->load(qtLangFile, qtLangPath)) {
qWarning() << "Could not load QT translation" << qtLangFile << "reverting to english :(";
}
qApp->installTranslator(qtranslator);