Browse Source

Do not use translator without translator tools

Ivan Savenko 2 years ago
parent
commit
9fb426edc1
3 changed files with 7 additions and 0 deletions
  1. 3 0
      CMakeLists.txt
  2. 2 0
      launcher/mainwindow_moc.cpp
  3. 2 0
      launcher/mainwindow_moc.h

+ 3 - 0
CMakeLists.txt

@@ -337,6 +337,9 @@ if(ENABLE_LAUNCHER OR ENABLE_EDITOR)
 	if (NOT Qt5LinguistTools_DIR)
 		set(ENABLE_TRANSLATIONS OFF)
 	endif()
+	if (ENABLE_TRANSLATIONS)
+		add_definitions(-DENABLE_QT_TRANSLATIONS)
+	endif()
 endif()
 
 if(ENABLE_NULLKILLER_AI)

+ 2 - 0
launcher/mainwindow_moc.cpp

@@ -137,6 +137,7 @@ void MainWindow::on_lobbyButton_clicked()
 
 void MainWindow::updateTranslation()
 {
+#ifdef ENABLE_QT_TRANSLATIONS
 	std::string languageCode = settings["general"]["language"].String();
 
 	QString translationFile = "./launcher/translations/" + QString::fromStdString(languageCode) + ".qm";
@@ -146,4 +147,5 @@ void MainWindow::updateTranslation()
 		logGlobal->error("Failed to load translation");
 	if (!qApp->installTranslator(&translator))
 		logGlobal->error("Failed to install translator");
+#endif
 }

+ 2 - 0
launcher/mainwindow_moc.h

@@ -26,7 +26,9 @@ class MainWindow : public QMainWindow
 {
 	Q_OBJECT
 
+#ifdef ENABLE_QT_TRANSLATIONS
 	QTranslator translator;
+#endif
 private:
 	Ui::MainWindow * ui;
 	void load();