From aa4406209575d292796cb6170e086bb22fde60a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Tue, 20 Dec 2022 08:46:59 +0100 Subject: [PATCH 1/3] Install qt translations on macOs --- CMakeLists.txt | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b15da692983..415e98f1691 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1484,19 +1484,6 @@ if(MSVC) endif() if(WIN32) - # qt_de.qm is just one arbitrary file in the directory that needs to be located; - # there is no particular reason to look for this file versus any other one in the directory. - find_file(QT_TRANSLATION_FILE qt_de.qm PATH_SUFFIXES share/qt5/translations) - get_filename_component(QT_TRANSLATIONS ${QT_TRANSLATION_FILE} DIRECTORY) - install( - DIRECTORY "${QT_TRANSLATIONS}" - DESTINATION "${MIXXX_INSTALL_DATADIR}" - # QT 5 translations have been separated into several files, and most of the qt_xx.qm files - # contain just shortcuts to load the qtbase, qtmultimedia etc files. - FILES_MATCHING REGEX - "qt_.+\.qm|qtbase_.*\.qm|qtmultimedia_.*\.qm|qtscript_.*\.qm|qtxmlpatterns_.*\.qm" - ) - # Qt 5 loads these ANGLE DLLs at runtime if the graphics driver is blocklisted. # Qt does not link these and vcpkg does not build them as a dependency of Qt, # so copy them manually. @@ -2173,6 +2160,21 @@ elseif(WIN32) endif() endif() +if(APPLE OR WIN32) + # qt_de.qm is just one arbitrary file in the directory that needs to be located; + # there is no particular reason to look for this file versus any other one in the directory. + find_file(QT_TRANSLATION_FILE qt_de.qm PATHS "${Qt5_DIR}/../../../translations" "${Qt5_DIR}/../../qt5/translations" REQUIRED NO_DEFAULT_PATH) + get_filename_component(QT_TRANSLATIONS ${QT_TRANSLATION_FILE} DIRECTORY) + install( + DIRECTORY "${QT_TRANSLATIONS}" + DESTINATION "${MIXXX_INSTALL_DATADIR}" + # QT 5 translations have been separated into several files, and most of the qt_xx.qm files + # contain just shortcuts to load the qtbase, qtmultimedia etc files. + FILES_MATCHING REGEX + "qt_.+\.qm|qtbase_.*\.qm|qtmultimedia_.*\.qm|qtscript_.*\.qm|qtxmlpatterns_.*\.qm" + ) +endif() + # QtScriptByteArray add_library(QtScriptByteArray STATIC EXCLUDE_FROM_ALL lib/qtscript-bytearray/bytearrayclass.cpp From ea0b93cebcec709f62fa39ea312402581c5b5eda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Mon, 16 Jan 2023 12:08:34 +0100 Subject: [PATCH 2/3] Improve warning messages when loading translations --- src/util/translations.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/util/translations.h b/src/util/translations.h index 832244d12b9..4a637a6431f 100644 --- a/src/util/translations.h +++ b/src/util/translations.h @@ -69,17 +69,17 @@ class Translations { // Load Qt translations for this locale from the system translation // path. This is the lowest precedence QTranslator. - installTranslations(pApp, + bool qtFound = installTranslations(pApp, locale, QStringLiteral("qt"), QLibraryInfo::location(QLibraryInfo::TranslationsPath), - true); + false); - // Load Qt translations for this locale from the Mixxx translations - // folder. - // Depending on the OS, this might not be necessary, so we don't warn - // on failure here. - installTranslations(pApp, locale, QStringLiteral("qt"), translationsPath, false); + if (!qtFound) { + // Alternative, load Qt translations for this locale from the Mixxx translations + // folder. + installTranslations(pApp, locale, QStringLiteral("qt"), translationsPath, true); + } // Load Mixxx specific translations for this locale from the Mixxx // translations folder. From 0a9daa7050dd9d485cd5ad095a180e2c9d61981e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Mon, 16 Jan 2023 15:30:51 +0100 Subject: [PATCH 3/3] Remove missleading debug message --- src/util/translations.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/util/translations.h b/src/util/translations.h index 4a637a6431f..f803e178379 100644 --- a/src/util/translations.h +++ b/src/util/translations.h @@ -97,10 +97,12 @@ class Translations { const bool success = pTranslator->load( locale, translation, QStringLiteral("_"), translationsPath); if (!success) { - ((warnOnFailure) ? qWarning() : qDebug()) - << "Failed to load" << translation << "translations for locale" - << locale.name() - << "from" << translationsPath; + if (warnOnFailure) { + qWarning() + << "Failed to load" << translation << "translations for locale" + << locale.name() + << "from" << translationsPath; + } delete pTranslator; return false; }