diff --git a/CHANGES b/CHANGES index 9d10876db..1ac7673fa 100644 --- a/CHANGES +++ b/CHANGES @@ -188,6 +188,7 @@ Misc: - 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 diff --git a/src/platform/qt/CMakeLists.txt b/src/platform/qt/CMakeLists.txt index 4391e09bc..c7347b41a 100644 --- a/src/platform/qt/CMakeLists.txt +++ b/src/platform/qt/CMakeLists.txt @@ -228,8 +228,20 @@ if(Qt5LinguistTools_FOUND) 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) diff --git a/src/platform/qt/SettingsView.cpp b/src/platform/qt/SettingsView.cpp index 363248d93..c25ea3448 100644 --- a/src/platform/qt/SettingsView.cpp +++ b/src/platform/qt/SettingsView.cpp @@ -169,7 +169,7 @@ SettingsView::SettingsView(ConfigController* controller, InputController* inputC 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")); diff --git a/src/platform/qt/main.cpp b/src/platform/qt/main.cpp index 812a86947..d42fa6281 100644 --- a/src/platform/qt/main.cpp +++ b/src/platform/qt/main.cpp @@ -58,6 +58,12 @@ int main(int argc, char* argv[]) { 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); diff --git a/src/platform/qt/ts.cmake b/src/platform/qt/ts.cmake index fdf58779a..b9cb4d781 100644 --- a/src/platform/qt/ts.cmake +++ b/src/platform/qt/ts.cmake @@ -1,7 +1,6 @@ -file(GLOB TRANSLATION_FILES "${QM_BASE}/*.qm") file(WRITE ${TRANSLATION_QRC} "\n\t\n") foreach(TS ${TRANSLATION_FILES}) get_filename_component(TS_BASE "${TS}" NAME) - file(APPEND ${TRANSLATION_QRC} "\t\t${TS_BASE}\n") + file(APPEND ${TRANSLATION_QRC} "\t\t${TS}\n") endforeach() file(APPEND ${TRANSLATION_QRC} "\t\n")