From ed5f65f36dd3f53c73198d422f7b3a6cf24703da Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Sun, 17 Jul 2022 22:11:03 -0700 Subject: [PATCH] Qt: Fix some translator lookups --- src/platform/qt/CMakeLists.txt | 8 +++--- src/platform/qt/GameBoy.cpp | 4 +-- src/platform/qt/SaveConverter.cpp | 36 ++++++++++++------------- src/platform/qt/library/LibraryTree.cpp | 10 +++---- 4 files changed, 28 insertions(+), 30 deletions(-) diff --git a/src/platform/qt/CMakeLists.txt b/src/platform/qt/CMakeLists.txt index 230a44271..e823a744e 100644 --- a/src/platform/qt/CMakeLists.txt +++ b/src/platform/qt/CMakeLists.txt @@ -330,17 +330,17 @@ if(${QT}LinguistTools_FOUND) file(GLOB TS_FILES "${CMAKE_CURRENT_SOURCE_DIR}/ts/${BINARY_NAME}-*.ts") if(UPDATE_TRANSLATIONS) if(TARGET Qt6::Core) - qt_create_translation(TRANSLATION_FILES ${SOURCE_FILES} ${UI_FILES} ${TS_FILES} OPTIONS -locations absolute -no-obsolete) + qt_create_translation(TRANSLATION_FILES ${SOURCE_FILES} ${UI_FILES} ${TS_FILES} ${CMAKE_CURRENT_SOURCE_DIR} OPTIONS -locations absolute -no-obsolete) else() - qt5_create_translation(TRANSLATION_FILES ${SOURCE_FILES} ${UI_FILES} ${TS_FILES} OPTIONS -locations absolute -no-obsolete) + qt5_create_translation(TRANSLATION_FILES ${SOURCE_FILES} ${UI_FILES} ${TS_FILES} ${CMAKE_CURRENT_SOURCE_DIR} OPTIONS -locations absolute -no-obsolete) endif() list(REMOVE_ITEM TS_FILES "${CMAKE_CURRENT_SOURCE_DIR}/ts/${BINARY_NAME}-template.ts") else() list(REMOVE_ITEM TS_FILES "${CMAKE_CURRENT_SOURCE_DIR}/ts/${BINARY_NAME}-template.ts") if(TARGET Qt6::Core) - qt_add_translation(TRANSLATION_FILES ${TS_FILES}) + qt_add_translation(TRANSLATION_FILES ${TS_FILES} ${CMAKE_CURRENT_SOURCE_DIR}) else() - qt5_add_translation(TRANSLATION_FILES ${TS_FILES}) + qt5_add_translation(TRANSLATION_FILES ${TS_FILES} ${CMAKE_CURRENT_SOURCE_DIR}) endif() endif() set(QT_QM_FILES) diff --git a/src/platform/qt/GameBoy.cpp b/src/platform/qt/GameBoy.cpp index 181461188..e0271d322 100644 --- a/src/platform/qt/GameBoy.cpp +++ b/src/platform/qt/GameBoy.cpp @@ -44,9 +44,7 @@ static const QList s_mbcList{ static QMap s_gbModelNames; static QMap s_mbcNames; -static QString tr(const char* str) { - return QCoreApplication::translate("Game Boy", str); -} +#define tr(STR) QCoreApplication::translate("QGBA::GameBoy", STR) QList GameBoy::modelList() { return s_gbModelList; diff --git a/src/platform/qt/SaveConverter.cpp b/src/platform/qt/SaveConverter.cpp index d904ed957..fd242af98 100644 --- a/src/platform/qt/SaveConverter.cpp +++ b/src/platform/qt/SaveConverter.cpp @@ -447,14 +447,14 @@ SaveConverter::AnnotatedSave::operator QString() const { QString typeFormat("%1"); QString endianStr; QString saveType; - QString format = QCoreApplication::translate("SaveConverter", "%1 %2 save game"); + QString format = QCoreApplication::translate("QGBA::SaveConverter", "%1 %2 save game"); switch (endianness) { case Endian::LITTLE: - endianStr = QCoreApplication::translate("SaveConverter", "little endian"); + endianStr = QCoreApplication::translate("QGBA::SaveConverter", "little endian"); break; case Endian::BIG: - endianStr = QCoreApplication::translate("SaveConverter", "big endian"); + endianStr = QCoreApplication::translate("QGBA::SaveConverter", "big endian"); break; default: break; @@ -465,15 +465,15 @@ SaveConverter::AnnotatedSave::operator QString() const { case mPLATFORM_GBA: switch (gba.type) { case SAVEDATA_SRAM: - typeFormat = QCoreApplication::translate("SaveConverter", "SRAM"); + typeFormat = QCoreApplication::translate("QGBA::SaveConverter", "SRAM"); break; case SAVEDATA_FLASH512: case SAVEDATA_FLASH1M: - typeFormat = QCoreApplication::translate("SaveConverter", "%1 flash"); + typeFormat = QCoreApplication::translate("QGBA::SaveConverter", "%1 flash"); break; case SAVEDATA_EEPROM: case SAVEDATA_EEPROM512: - typeFormat = QCoreApplication::translate("SaveConverter", "%1 EEPROM"); + typeFormat = QCoreApplication::translate("QGBA::SaveConverter", "%1 EEPROM"); break; default: break; @@ -485,29 +485,29 @@ SaveConverter::AnnotatedSave::operator QString() const { switch (gb.type) { case GB_MBC_AUTODETECT: if (size & 0xFF) { - typeFormat = QCoreApplication::translate("SaveConverter", "%1 SRAM + RTC"); + typeFormat = QCoreApplication::translate("QGBA::SaveConverter", "%1 SRAM + RTC"); } else { - typeFormat = QCoreApplication::translate("SaveConverter", "%1 SRAM"); + typeFormat = QCoreApplication::translate("QGBA::SaveConverter", "%1 SRAM"); } break; case GB_MBC2: if (size == 0x100) { - typeFormat = QCoreApplication::translate("SaveConverter", "packed MBC2"); + typeFormat = QCoreApplication::translate("QGBA::SaveConverter", "packed MBC2"); } else { - typeFormat = QCoreApplication::translate("SaveConverter", "unpacked MBC2"); + typeFormat = QCoreApplication::translate("QGBA::SaveConverter", "unpacked MBC2"); } break; case GB_MBC6: if (size == GB_SIZE_MBC6_FLASH) { - typeFormat = QCoreApplication::translate("SaveConverter", "MBC6 flash"); + typeFormat = QCoreApplication::translate("QGBA::SaveConverter", "MBC6 flash"); } else if (size > GB_SIZE_MBC6_FLASH) { - typeFormat = QCoreApplication::translate("SaveConverter", "MBC6 combined SRAM + flash"); + typeFormat = QCoreApplication::translate("QGBA::SaveConverter", "MBC6 combined SRAM + flash"); } else { - typeFormat = QCoreApplication::translate("SaveConverter", "MBC6 SRAM"); + typeFormat = QCoreApplication::translate("QGBA::SaveConverter", "MBC6 SRAM"); } break; case GB_TAMA5: - typeFormat = QCoreApplication::translate("SaveConverter", "TAMA5"); + typeFormat = QCoreApplication::translate("QGBA::SaveConverter", "TAMA5"); break; default: break; @@ -519,17 +519,17 @@ SaveConverter::AnnotatedSave::operator QString() const { } saveType = typeFormat.arg(sizeStr); if (!endianStr.isEmpty()) { - saveType = QCoreApplication::translate("SaveConverter", "%1 (%2)").arg(saveType).arg(endianStr); + saveType = QCoreApplication::translate("QGBA::SaveConverter", "%1 (%2)").arg(saveType).arg(endianStr); } switch (container) { case Container::SAVESTATE: - format = QCoreApplication::translate("SaveConverter", "%1 save state with embedded %2 save game"); + format = QCoreApplication::translate("QGBA::SaveConverter", "%1 save state with embedded %2 save game"); break; case Container::SHARKPORT: - format = QCoreApplication::translate("SaveConverter", "%1 SharkPort %2 save game"); + format = QCoreApplication::translate("QGBA::SaveConverter", "%1 SharkPort %2 save game"); break; case Container::GSV: - format = QCoreApplication::translate("SaveConverter", "%1 GameShark Advance SP %2 save game"); + format = QCoreApplication::translate("QGBA::SaveConverter", "%1 GameShark Advance SP %2 save game"); break; case Container::NONE: break; diff --git a/src/platform/qt/library/LibraryTree.cpp b/src/platform/qt/library/LibraryTree.cpp index 179edd95c..37d07e3e7 100644 --- a/src/platform/qt/library/LibraryTree.cpp +++ b/src/platform/qt/library/LibraryTree.cpp @@ -48,11 +48,11 @@ LibraryTree::LibraryTree(LibraryController* parent) m_widget->setAlternatingRowColors(true); QTreeWidgetItem* header = new QTreeWidgetItem({ - QApplication::translate("LibraryTree", "Name", nullptr), - QApplication::translate("LibraryTree", "Location", nullptr), - QApplication::translate("LibraryTree", "Platform", nullptr), - QApplication::translate("LibraryTree", "Size", nullptr), - QApplication::translate("LibraryTree", "CRC32", nullptr), + QApplication::translate("QGBA::LibraryTree", "Name", nullptr), + QApplication::translate("QGBA::LibraryTree", "Location", nullptr), + QApplication::translate("QGBA::LibraryTree", "Platform", nullptr), + QApplication::translate("QGBA::LibraryTree", "Size", nullptr), + QApplication::translate("QGBA::LibraryTree", "CRC32", nullptr), }); header->setTextAlignment(3, Qt::AlignTrailing | Qt::AlignVCenter); m_widget->setHeaderItem(header);