QTfrontend/net/tcpBase.cpp
changeset 14599 b86e6e4f3c58
parent 13512 4c5c8a83e298
child 15258 1ce9b717bb41
--- a/QTfrontend/net/tcpBase.cpp	Wed Jan 16 00:01:29 2019 +0100
+++ b/QTfrontend/net/tcpBase.cpp	Wed Jan 16 00:37:26 2019 +0100
@@ -21,10 +21,12 @@
 #include <QImage>
 #include <QThread>
 #include <QApplication>
+#include <QProcessEnvironment>
 
 #include "tcpBase.h"
 #include "hwconsts.h"
 #include "MessageDialog.h"
+#include "gameuiconfig.h"
 
 #ifdef HWLIBRARY
 extern "C" {
@@ -104,11 +106,12 @@
 
 }
 
-TCPBase::TCPBase(bool demoMode, QObject *parent) :
+TCPBase::TCPBase(bool demoMode, bool usesCustomLanguage, QObject *parent) :
     QObject(parent),
     m_hasStarted(false),
     m_isDemoMode(demoMode),
     m_connected(false),
+    m_usesCustomLanguage(usesCustomLanguage),
     IPCSocket(0)
 {
     process = 0;
@@ -183,6 +186,18 @@
     process->setProcessChannelMode(QProcess::ForwardedChannels);
 #endif
 
+    // If game config uses non-system locale, we set the environment
+    // of the engine first
+    if(m_usesCustomLanguage)
+    {
+        QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
+        QString hwengineLang = QLocale().name() + ".UTF8";
+        qDebug("Setting hwengine environment: LANG=%s", qPrintable(hwengineLang));
+        // TODO: Check if this is correct and works on all systems
+        env.insert("LANG", QLocale().name() + ".UTF8");
+        process->setProcessEnvironment(env);
+    }
+    qDebug("Starting hwengine ...");
     process->start(bindir->absolutePath() + "/hwengine", arguments);
 #endif
     m_hasStarted = true;