Qt: Fix translation interface

This commit is contained in:
Jeffrey Pfau 2016-09-05 22:38:39 -07:00
parent 6dd39389e0
commit dbe55c2fa8
4 changed files with 34 additions and 1341 deletions

View File

@ -189,13 +189,18 @@ endif()
find_package(Qt5LinguistTools)
if(Qt5LinguistTools_FOUND)
set(TRANSLATION_FILES)
file(GLOB TS_FILES ts/*.ts)
set(TRANSLATION_QRC "${CMAKE_CURRENT_BINARY_DIR}/ts.qrc")
file(GLOB TS_FILES "${CMAKE_CURRENT_SOURCE_DIR}/ts/${BINARY_NAME}-*.ts")
if(UPDATE_TRANSLATIONS)
qt5_create_translation(TRANSLATION_FILES ${SOURCE_FILES} ${UI_FILES} ${TS_FILES})
else()
qt5_add_translation(TRANSLATION_FILES ${TS_FILES})
endif()
list(APPEND RESOURCES ${TRANSLATION_FILES})
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"
DEPENDS ${TRANSLATION_FILES})
qt5_add_resources(TRANSLATION_RESOURCES ${TRANSLATION_QRC})
list(APPEND RESOURCES ${TRANSLATION_RESOURCES})
endif()
add_executable(${BINARY_NAME}-qt WIN32 MACOSX_BUNDLE main.cpp ${CMAKE_SOURCE_DIR}/res/mgba.icns ${SOURCE_FILES} ${PLATFORM_SRC} ${UI_FILES} ${AUDIO_SRC} ${RESOURCES})

View File

@ -14,6 +14,7 @@
#include <QFileInfo>
#include <QFileOpenEvent>
#include <QIcon>
#include <QTranslator>
extern "C" {
#include "core/version.h"
@ -43,6 +44,12 @@ GBAApp::GBAApp(int& argc, char* argv[])
setWindowIcon(QIcon(":/res/mgba-1024.png"));
#endif
QTranslator* translator = new QTranslator(this);
if (translator->load(QLocale("es"), QLatin1String(binaryName), QLatin1String("-"), QLatin1String(":/translations"))) {
installTranslator(translator);
}
SocketSubsystemInit();
qRegisterMetaType<const uint32_t*>("const uint32_t*");
qRegisterMetaType<mCoreThread*>("mCoreThread*");

6
src/platform/qt/ts.cmake Normal file
View File

@ -0,0 +1,6 @@
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")
endforeach()
file(APPEND ${TRANSLATION_QRC} "\t</qresource>\n</RCC>")

File diff suppressed because it is too large Load Diff