Skip to content

Commit 108a885

Browse files
committed
Translating new/edit VM dialog
1 parent 5c17ad0 commit 108a885

19 files changed

+600
-70
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# EmuGUI v0.6
22

33
- A dialog for VMs which are created with a version of EmuGUI too new has been added.
4-
- The main file is now translated into English, German, and also, English with parts of Ukrainian is supported
4+
- The main and new/edit VM files are now translated into English, German, and also, English with parts of Ukrainian is supported
55

66
# EmuGUI v0.5.2
77

1.78 KB
Binary file not shown.
1.73 KB
Binary file not shown.

dialogExecution/editVirtualMachine.py

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,18 @@
88
import subprocess
99
from dialogExecution.vhdExistsDialog import VhdAlreadyExists
1010
from dialogExecution.vmExistsDialog import VmAlreadyExistsDialog
11+
import translations.de
12+
import translations.uk
13+
import translations.en
14+
import locale
1115

1216
class EditVirtualMachineDialog(QDialog, Ui_Dialog):
1317
def __init__(self, parent=None):
1418
# This is preparing the dialog required.
1519
super().__init__(parent)
1620
self.setupUi(self)
1721
self.connectSignalsSlots()
22+
self.langDetect()
1823
self.vmSpecs = self.readTempVmFile()
1924

2025
try:
@@ -95,6 +100,101 @@ def connectSignalsSlots(self):
95100
self.pushButton_20.clicked.connect(self.finishCreation)
96101
self.pushButton_21.clicked.connect(self.close)
97102

103+
def langDetect(self):
104+
select_language = """
105+
SELECT name, value FROM settings
106+
WHERE name = "lang";
107+
"""
108+
109+
if platform.system() == "Windows":
110+
connection = platformSpecific.windowsSpecific.setupWindowsBackend()
111+
112+
else:
113+
connection = platformSpecific.unixSpecific.setupUnixBackend()
114+
115+
cursor = connection.cursor()
116+
117+
try:
118+
cursor.execute(select_language)
119+
connection.commit()
120+
result = cursor.fetchall()
121+
122+
# Language modes
123+
# system: language of OS
124+
# en: English
125+
# de: German
126+
langmode = "system"
127+
128+
try:
129+
qemu_img_slot = str(result[0])
130+
131+
i = 0
132+
133+
if result[0][1] == "default":
134+
while i < self.comboBox_4.count():
135+
if self.comboBox_4.itemText(i) == "System default":
136+
self.comboBox_4.setCurrentIndex(i)
137+
break
138+
139+
i += 1
140+
141+
elif result[0][1] == "en":
142+
while i < self.comboBox_4.count():
143+
if self.comboBox_4.itemText(i) == "English":
144+
self.comboBox_4.setCurrentIndex(i)
145+
break
146+
147+
i += 1
148+
149+
langmode = "en"
150+
151+
elif result[0][1] == "de":
152+
while i < self.comboBox_4.count():
153+
if self.comboBox_4.itemText(i) == "Deutsch":
154+
self.comboBox_4.setCurrentIndex(i)
155+
break
156+
157+
i += 1
158+
159+
langmode = "de"
160+
161+
elif result[0][1] == "uk":
162+
while i < self.comboBox_4.count():
163+
if self.comboBox_4.itemText(i) == "Українська":
164+
self.comboBox_4.setCurrentIndex(i)
165+
break
166+
167+
i += 1
168+
169+
langmode = "uk"
170+
171+
self.setLanguage(langmode)
172+
print("The query was executed successfully. The language slot already is in the database.")
173+
174+
except:
175+
langmode = "system"
176+
self.setLanguage(langmode)
177+
print("The query was executed successfully. The language slot has been created.")
178+
179+
except sqlite3.Error as e:
180+
print(f"The SQLite module encountered an error: {e}.")
181+
182+
def setLanguage(self, langmode):
183+
if langmode == "system":
184+
languageToUse = locale.getlocale()[0]
185+
186+
else:
187+
languageToUse = langmode
188+
189+
if languageToUse.startswith("de"):
190+
translations.de.translateNewVmDE(self)
191+
192+
elif languageToUse.startswith("uk"):
193+
translations.uk.translateNewVmUK(self)
194+
195+
else:
196+
translations.en.translateNewVmEN(self)
197+
98198
# First, it will check the architecture of your VM.
99199

100200
def machineCpuI386Amd64(self, machine, cpu):
@@ -193,6 +293,7 @@ def readTempVmFile(self):
193293
# Setting VM variables
194294

195295
self.lineEdit.setText(vmSpecs[0])
296+
self.setWindowTitle(f"EmuGUI - Edit {vmSpecs[0]}")
196297

197298
if vmSpecs[1] == "i386":
198299
self.comboBox.setCurrentIndex(0)

dialogExecution/newVirtualMachine.py

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,18 @@
88
import subprocess
99
from dialogExecution.vhdExistsDialog import VhdAlreadyExists
1010
from dialogExecution.vmExistsDialog import VmAlreadyExistsDialog
11+
import translations.de
12+
import translations.uk
13+
import translations.en
14+
import locale
1115

1216
class NewVirtualMachineDialog(QDialog, Ui_Dialog):
1317
def __init__(self, parent=None):
1418
# Initializing the dialog for creating the VM.
1519

1620
super().__init__(parent)
1721
self.setupUi(self)
22+
self.langDetect()
1823
self.setWindowTitle("EmuGUI - Create new VM")
1924

2025
try:
@@ -95,6 +100,101 @@ def connectSignalsSlots(self):
95100
self.pushButton_20.clicked.connect(self.finishCreation)
96101
self.pushButton_21.clicked.connect(self.close)
97102

103+
def langDetect(self):
104+
select_language = """
105+
SELECT name, value FROM settings
106+
WHERE name = "lang";
107+
"""
108+
109+
if platform.system() == "Windows":
110+
connection = platformSpecific.windowsSpecific.setupWindowsBackend()
111+
112+
else:
113+
connection = platformSpecific.unixSpecific.setupUnixBackend()
114+
115+
cursor = connection.cursor()
116+
117+
try:
118+
cursor.execute(select_language)
119+
connection.commit()
120+
result = cursor.fetchall()
121+
122+
# Language modes
123+
# system: language of OS
124+
# en: English
125+
# de: German
126+
langmode = "system"
127+
128+
try:
129+
qemu_img_slot = str(result[0])
130+
131+
i = 0
132+
133+
if result[0][1] == "default":
134+
while i < self.comboBox_4.count():
135+
if self.comboBox_4.itemText(i) == "System default":
136+
self.comboBox_4.setCurrentIndex(i)
137+
break
138+
139+
i += 1
140+
141+
elif result[0][1] == "en":
142+
while i < self.comboBox_4.count():
143+
if self.comboBox_4.itemText(i) == "English":
144+
self.comboBox_4.setCurrentIndex(i)
145+
break
146+
147+
i += 1
148+
149+
langmode = "en"
150+
151+
elif result[0][1] == "de":
152+
while i < self.comboBox_4.count():
153+
if self.comboBox_4.itemText(i) == "Deutsch":
154+
self.comboBox_4.setCurrentIndex(i)
155+
break
156+
157+
i += 1
158+
159+
langmode = "de"
160+
161+
elif result[0][1] == "uk":
162+
while i < self.comboBox_4.count():
163+
if self.comboBox_4.itemText(i) == "Українська":
164+
self.comboBox_4.setCurrentIndex(i)
165+
break
166+
167+
i += 1
168+
169+
langmode = "uk"
170+
171+
self.setLanguage(langmode)
172+
print("The query was executed successfully. The language slot already is in the database.")
173+
174+
except:
175+
langmode = "system"
176+
self.setLanguage(langmode)
177+
print("The query was executed successfully. The language slot has been created.")
178+
179+
except sqlite3.Error as e:
180+
print(f"The SQLite module encountered an error: {e}.")
181+
182+
def setLanguage(self, langmode):
183+
if langmode == "system":
184+
languageToUse = locale.getlocale()[0]
185+
186+
else:
187+
languageToUse = langmode
188+
189+
if languageToUse.startswith("de"):
190+
translations.de.translateNewVmDE(self)
191+
192+
elif languageToUse.startswith("uk"):
193+
translations.uk.translateNewVmUK(self)
194+
195+
else:
196+
translations.en.translateNewVmEN(self)
197+
98198
def archSystem(self):
99199
# Here, it checks the name first, than the architecture.
100200

main.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ def __init__(self, parent=None):
3131
self.connectSignalsSlots()
3232
self.timer = QTimer()
3333
self.timer.timeout.connect(self.updateVmList)
34-
#self.setLanguage()
35-
self.label_8.setText("EmuGUI v0.6.0.1 (pre-release)")
34+
self.label_8.setText("EmuGUI v0.6.0.2 (pre-release)")
3635
self.setWindowTitle("EmuGUI")
3736

3837
try:
@@ -41,7 +40,7 @@ def __init__(self, parent=None):
4140
except:
4241
pass
4342

44-
self.versionCode = 5010
43+
self.versionCode = 5011
4544

4645
if platform.system() == "Windows":
4746
self.connection = platformSpecific.windowsSpecific.setupWindowsBackend()
2.67 KB
Binary file not shown.
2.55 KB
Binary file not shown.
2.55 KB
Binary file not shown.

0 commit comments

Comments
 (0)