all repos — mgba @ 253719d7a14e0002c8e987beff4c6a6a3604704f

mGBA Game Boy Advance Emulator

Qt: Properly ship Qt translations
Vicki Pfau vi@endrift.com
Mon, 10 Jul 2017 17:05:08 -0700
commit

253719d7a14e0002c8e987beff4c6a6a3604704f

parent

2ff1deed60abc17e25c387ca862183c1402f59df

M CHANGESCHANGES

@@ -188,6 +188,7 @@ - GB Serialize: Add MBC state serialization

- Qt: Dismiss game crashing/failing dialogs when a new game loads - GBA Memory: Call crash callbacks regardless of if hard crash is enabled - SDL: Remove writing back obtained samples (fixes mgba.io/i/768) + - Qt: Properly ship Qt translations 0.6 beta 1: (2017-06-29) - Initial beta for 0.6
M src/platform/qt/CMakeLists.txtsrc/platform/qt/CMakeLists.txt

@@ -228,8 +228,20 @@ qt5_create_translation(TRANSLATION_FILES ${SOURCE_FILES} ${UI_FILES} ${TS_FILES} OPTIONS -locations absolute -no-obsolete)

else() qt5_add_translation(TRANSLATION_FILES ${TS_FILES}) endif() + set(QT_QM_FILES) + if(QT_STATIC) + get_target_property(QT_CORE_LOCATION Qt5::Core LOCATION) + get_filename_component(QT_CORE_LOCATION ${QT_CORE_LOCATION} DIRECTORY) + get_filename_component(QT_QM_LOCATION "${QT_CORE_LOCATION}/../translations" ABSOLUTE) + foreach(TS ${TS_FILES}) + get_filename_component(TS ${TS} NAME) + string(REGEX REPLACE "${BINARY_NAME}-(.*).ts$" "qtbase_\\1.qm" QT_QM "${TS}") + list(APPEND QT_QM_FILES "${QT_QM_LOCATION}/${QT_QM}") + endforeach() + list(APPEND TRANSLATION_FILES ${QT_QM_FILES}) + endif() add_custom_command(OUTPUT ${TRANSLATION_QRC} - COMMAND ${CMAKE_COMMAND} -DTRANSLATION_QRC:FILEPATH="${TRANSLATION_QRC}" -DQM_BASE="${CMAKE_CURRENT_BINARY_DIR}" -P "${CMAKE_CURRENT_SOURCE_DIR}/ts.cmake" + COMMAND ${CMAKE_COMMAND} -DTRANSLATION_QRC:FILEPATH="${TRANSLATION_QRC}" -DQM_BASE="${CMAKE_CURRENT_BINARY_DIR}" "-DTRANSLATION_FILES='${TRANSLATION_FILES}'" -P "${CMAKE_CURRENT_SOURCE_DIR}/ts.cmake" DEPENDS ${TRANSLATION_FILES}) qt5_add_resources(TRANSLATION_RESOURCES ${TRANSLATION_QRC}) list(APPEND RESOURCES ${TRANSLATION_RESOURCES})

@@ -263,7 +275,6 @@ if(APPLE OR WIN32)

set_target_properties(${BINARY_NAME}-qt PROPERTIES OUTPUT_NAME ${PROJECT_NAME}) endif() if(APPLE) - message(STATUS ${CMAKE_SYSTEM_NAME}) if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin") get_target_property(QTCOCOA Qt5::QCocoaIntegrationPlugin LOCATION) get_target_property(COREAUDIO Qt5::CoreAudioPlugin LOCATION)
M src/platform/qt/SettingsView.cppsrc/platform/qt/SettingsView.cpp

@@ -169,7 +169,7 @@

m_ui.languages->setItemData(0, QLocale("en")); QDir ts(":/translations/"); for (auto name : ts.entryList()) { - if (!name.endsWith(".qm")) { + if (!name.endsWith(".qm") || !name.startsWith(binaryName)) { continue; } QLocale locale(name.remove(QString("%0-").arg(binaryName)).remove(".qm"));
M src/platform/qt/main.cppsrc/platform/qt/main.cpp

@@ -58,6 +58,12 @@ QTranslator qtTranslator;

qtTranslator.load(locale, "qt", "_", QLibraryInfo::location(QLibraryInfo::TranslationsPath)); application.installTranslator(&qtTranslator); +#ifdef QT_STATIC + QTranslator qtStaticTranslator; + qtStaticTranslator.load(locale, "qtbase", "_", ":/translations/"); + application.installTranslator(&qtStaticTranslator); +#endif + QTranslator langTranslator; langTranslator.load(locale, binaryName, "-", ":/translations/"); application.installTranslator(&langTranslator);
M src/platform/qt/ts.cmakesrc/platform/qt/ts.cmake

@@ -1,7 +1,6 @@

-file(GLOB TRANSLATION_FILES "${QM_BASE}/*.qm") file(WRITE ${TRANSLATION_QRC} "<RCC>\n\t<qresource prefix=\"/translations/\">\n") foreach(TS ${TRANSLATION_FILES}) get_filename_component(TS_BASE "${TS}" NAME) - file(APPEND ${TRANSLATION_QRC} "\t\t<file>${TS_BASE}</file>\n") + file(APPEND ${TRANSLATION_QRC} "\t\t<file alias=\"${TS_BASE}\">${TS}</file>\n") endforeach() file(APPEND ${TRANSLATION_QRC} "\t</qresource>\n</RCC>")