From 3da5d58af9a10a88e213a0d1ad64984032f3f795 Mon Sep 17 00:00:00 2001
From: tanyulong <tanyulong@kylinos.cn>
Date: Mon, 1 Nov 2021 17:02:58 +0800
Subject: [PATCH] adjust the sequence to make translation file loaded first

---
 tools/main.cpp | 31 ++++++++++++++++++++++---------
 1 file changed, 22 insertions(+), 9 deletions(-)

diff --git a/tools/main.cpp b/tools/main.cpp
index 58459e4..94f9d72 100755
--- a/tools/main.cpp
+++ b/tools/main.cpp
@@ -70,6 +70,19 @@ int main(int argc, char* argv[])
     QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
 
     QApplication a(argc, argv);
+    
+    // Load ts files
+    const QString locale = QLocale::system().name();
+    QTranslator translator;
+    qDebug() << "local: " << locale;
+    qDebug() << "path: " << QStringLiteral(UKUI_TRANSLATIONS_DIR) + QStringLiteral("/ukui-session-manager");
+    if (translator.load(locale, QStringLiteral(UKUI_TRANSLATIONS_DIR) + QStringLiteral("/ukui-session-manager"))) {
+	    a.installTranslator(&translator);
+    } else {
+	    qDebug() << "Load translations file failed!";
+    }
+
+		    
 
     UkuiPower powermanager(&a);
     bool flag = true;
@@ -120,15 +133,15 @@ int main(int argc, char* argv[])
         gs->set("win-key-release",true);
 
         // Load ts files
-        const QString locale = QLocale::system().name();
-        QTranslator translator;
-        qDebug() << "local: " << locale;
-        qDebug() << "path: " << QStringLiteral(UKUI_TRANSLATIONS_DIR) + QStringLiteral("/ukui-session-manager");
-        if (translator.load(locale, QStringLiteral(UKUI_TRANSLATIONS_DIR) + QStringLiteral("/ukui-session-manager"))) {
-           a.installTranslator(&translator);
-        } else {
-           qDebug() << "Load translations file failed!";
-        }
+//        const QString locale = QLocale::system().name();
+//        QTranslator translator;
+//        qDebug() << "local: " << locale;
+//        qDebug() << "path: " << QStringLiteral(UKUI_TRANSLATIONS_DIR) + QStringLiteral("/ukui-session-manager");
+//        if (translator.load(locale, QStringLiteral(UKUI_TRANSLATIONS_DIR) + QStringLiteral("/ukui-session-manager"))) {
+//           a.installTranslator(&translator);
+//        } else {
+//           qDebug() << "Load translations file failed!";
+//        }
 
         MainWindow *w = new MainWindow();
 
-- 
2.30.0

