diff --git a/CMakeLists.txt b/CMakeLists.txt index 95fe102a4..759095988 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -316,8 +316,8 @@ find_package(TBB REQUIRED) if(ENABLE_LAUNCHER OR ENABLE_EDITOR) # Widgets finds its own dependencies (QtGui and QtCore). - find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Network) - find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Network) + find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Network LinguistTools) + find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Network LinguistTools) endif() if(ENABLE_LUA) diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index acfa79e0e..6883e4e9a 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -62,6 +62,13 @@ set(launcher_FORMS lobby/lobbyroomrequest_moc.ui ) +set(launcher_TS + translation/english.ts + translation/german.ts + translation/polish.ts + translation/russian.ts + translation/ukrainian.ts) + if(APPLE_IOS) list(APPEND launcher_SRCS ios/main.m @@ -83,13 +90,13 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) if(TARGET Qt6::Core) qt_wrap_ui(launcher_UI_HEADERS ${launcher_FORMS}) + qt_add_translation( launcher_QM ${launcher_TS} ) else() + set_source_files_properties(${launcher_TS} PROPERTIES OUTPUT_LOCATION ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/launcher/translations) qt5_wrap_ui(launcher_UI_HEADERS ${launcher_FORMS}) + qt5_add_translation( launcher_QM ${launcher_TS} ) endif() -find_package(Qt5LinguistTools) -set(launcher_TS translation/launcher_en.ts translation/launcher_pl.ts translation/launcher_ru.ts translation/launcher_uk.ts) -qt5_add_translation( QM_FILES ${launcher_TS} ) if(WIN32) set(launcher_ICON VCMI_launcher.rc) @@ -98,7 +105,7 @@ endif() if(BUILD_SINGLE_APP) add_library(vcmilauncher STATIC ${launcher_SRCS} ${launcher_HEADERS} ${launcher_UI_HEADERS}) else() - add_executable(vcmilauncher WIN32 ${QM_FILES} ${launcher_SRCS} ${launcher_HEADERS} ${launcher_UI_HEADERS} ${launcher_ICON}) + add_executable(vcmilauncher WIN32 ${launcher_QM} ${launcher_SRCS} ${launcher_HEADERS} ${launcher_UI_HEADERS} ${launcher_ICON}) endif() if(WIN32) @@ -130,7 +137,7 @@ vcmi_set_output_dir(vcmilauncher "") enable_pch(vcmilauncher) if(APPLE_IOS) - set(ICONS_DESTINATION ${DATA_DIR}) + set(RESOURCES_DESTINATION ${DATA_DIR}) # workaround https://github.com/conan-io/conan-center-index/issues/13332 if(USING_CONAN) @@ -144,7 +151,7 @@ if(APPLE_IOS) ) endif() else() - set(ICONS_DESTINATION ${DATA_DIR}/launcher) + set(RESOURCES_DESTINATION ${DATA_DIR}/launcher) # Copy to build directory for easier debugging add_custom_command(TARGET vcmilauncher POST_BUILD @@ -161,4 +168,5 @@ else() endif() endif() -install(DIRECTORY icons DESTINATION ${ICONS_DESTINATION}) +install(DIRECTORY icons DESTINATION ${RESOURCES_DESTINATION}) +install(DIRECTORY ts DESTINATION ${RESOURCES_DESTINATION}) diff --git a/launcher/mainwindow_moc.cpp b/launcher/mainwindow_moc.cpp index 5ec14e8a2..a88c3845f 100644 --- a/launcher/mainwindow_moc.cpp +++ b/launcher/mainwindow_moc.cpp @@ -129,7 +129,7 @@ void MainWindow::updateTranslation() { std::string languageCode = settings["general"]["language"].String(); - QString translationFile = "./launcher_" + QString::fromStdString(languageCode) + ".qm"; + QString translationFile = "./launcher/translations/" + QString::fromStdString(languageCode) + ".qm"; qApp->removeTranslator(&translator); if (!translator.load(translationFile)) diff --git a/launcher/modManager/cmodlist.cpp b/launcher/modManager/cmodlist.cpp index 0146c983c..fbee206c8 100644 --- a/launcher/modManager/cmodlist.cpp +++ b/launcher/modManager/cmodlist.cpp @@ -158,8 +158,7 @@ QString CModEntry::getName() const QVariant CModEntry::getValue(QString value) const { - QString lang = QString::fromStdString(settings["general"]["language"].String()); - QString langValue = "translation_" + lang; + QString langValue = QString::fromStdString(settings["general"]["language"].String()); // Priorities // 1) data from newest version