浏览代码

Compiled launcher translations are now in launcher/translations/ dir

Ivan Savenko 2 年之前
父节点
当前提交
b012cd9490
共有 4 个文件被更改,包括 19 次插入12 次删除
  1. 2 2
      CMakeLists.txt
  2. 15 7
      launcher/CMakeLists.txt
  3. 1 1
      launcher/mainwindow_moc.cpp
  4. 1 2
      launcher/modManager/cmodlist.cpp

+ 2 - 2
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)

+ 15 - 7
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})

+ 1 - 1
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))

+ 1 - 2
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