diff --git a/src/platform/qt/CMakeLists.txt b/src/platform/qt/CMakeLists.txt index bde726ede..b2804036b 100644 --- a/src/platform/qt/CMakeLists.txt +++ b/src/platform/qt/CMakeLists.txt @@ -236,7 +236,7 @@ if(Qt5LinguistTools_FOUND) qt5_add_translation(TRANSLATION_FILES ${TS_FILES}) endif() add_custom_command(OUTPUT ${TRANSLATION_QRC} - COMMAND ${CMAKE_COMMAND} -DTRANSLATION_QRC:FILEPATH="${TRANSLATION_QRC}" -DTRANSLATION_FILES="${TRANSLATION_FILES}" -P "${CMAKE_CURRENT_SOURCE_DIR}/ts.cmake" + COMMAND ${CMAKE_COMMAND} -DTRANSLATION_QRC:FILEPATH="${TRANSLATION_QRC}" -DQM_BASE="${CMAKE_CURRENT_BINARY_DIR}" -P "${CMAKE_CURRENT_SOURCE_DIR}/ts.cmake" DEPENDS ${TRANSLATION_FILES}) qt5_add_resources(TRANSLATION_RESOURCES ${TRANSLATION_QRC}) list(APPEND RESOURCES ${TRANSLATION_RESOURCES}) diff --git a/src/platform/qt/main.cpp b/src/platform/qt/main.cpp index 3dfca440b..29df3ea8d 100644 --- a/src/platform/qt/main.cpp +++ b/src/platform/qt/main.cpp @@ -6,6 +6,11 @@ #include "GBAApp.h" #include "Window.h" +#include +#include + +#include + #ifdef QT_STATIC #include #ifdef _WIN32 @@ -18,5 +23,16 @@ Q_IMPORT_PLUGIN(QWindowsAudioPlugin); int main(int argc, char* argv[]) { QGBA::GBAApp application(argc, argv); + + QLocale locale = QLocale::system(); + + QTranslator qtTranslator; + qtTranslator.load(locale, "qt", "_", QLibraryInfo::location(QLibraryInfo::TranslationsPath)); + application.installTranslator(&qtTranslator); + + QTranslator langTranslator; + langTranslator.load(locale, binaryName, "-", ":/translations/"); + application.installTranslator(&langTranslator); + return application.exec(); } diff --git a/src/platform/qt/ts.cmake b/src/platform/qt/ts.cmake index 0c1e3c9bb..3bb8c2e43 100644 --- a/src/platform/qt/ts.cmake +++ b/src/platform/qt/ts.cmake @@ -1,5 +1,8 @@ +file(GLOB TRANSLATION_FILES "${QM_BASE}/*.qm") file(WRITE ${TRANSLATION_QRC} "\n\t\n") +message(STATUS ${TRANSLATION_FILES}) foreach(TS ${TRANSLATION_FILES}) + message(STATUS ${TS}) get_filename_component(TS_BASE "${TS}" NAME) file(APPEND ${TRANSLATION_QRC} "\t\t${TS_BASE}\n") endforeach()