Skip to content

Commit fd7527a

Browse files
authored
MWP-68 Support for different languages (#77)
* Added multilanguage support. Added ru_RU locale. * Package name added; plugin.json update.
1 parent e46eb7b commit fd7527a

11 files changed

+1031
-72
lines changed

MKSOutputDevice.py

Lines changed: 48 additions & 36 deletions
Large diffs are not rendered by default.

MKSOutputDevicePlugin.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717

1818
from UM.Message import Message
1919
from UM.i18n import i18nCatalog
20-
i18n_catalog = i18nCatalog("cura")
20+
21+
# catalog = i18nCatalog("cura")
2122

2223
import time
2324
import json
@@ -26,6 +27,8 @@
2627

2728
from cura.CuraApplication import CuraApplication
2829

30+
catalog = i18nCatalog("mksplugin")
31+
2932
@signalemitter
3033
class MKSOutputDevicePlugin(QObject, OutputDevicePlugin):
3134
def __init__(self):
@@ -179,12 +182,12 @@ def _onPrinterConnectionStateChanged(self, key):
179182
# Logger.log("d", "mks add output device--------ok--------- %s" % self._printers[key].isConnected())
180183
if self._error_message:
181184
self._error_message.hide()
182-
name = "Printer connected successfully!"
183-
if CuraApplication.getInstance().getPreferences().getValue("general/language") == "zh_CN":
184-
name = self._printers[key]._properties.get(b"name", b"").decode("utf-8") + " 打印机连接成功"
185-
else:
186-
name = self._printers[key]._properties.get(b"name", b"").decode("utf-8") + " printer connected successfully!"
187-
self._error_message = Message(name)
185+
# name = "Printer connected successfully!"
186+
# if CuraApplication.getInstance().getPreferences().getValue("general/language") == "zh_CN":
187+
# name = self._printers[key]._properties.get(b"name", b"").decode("utf-8") + " 打印机连接成功"
188+
# else:
189+
# name = self._printers[key]._properties.get(b"name", b"").decode("utf-8") + " printer connected successfully!"
190+
self._error_message = Message(catalog.i18nc("@info:status Don't translate the XML tags <message>!", "<message>{0}</message> printer connected successfully!").format(self._printers[key]._properties.get(b"name", b"").decode("utf-8")))
188191
self._error_message.show()
189192
self.getOutputDeviceManager().addOutputDevice(self._printers[key])
190193
else:

MachineConfig.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@
2323

2424
from PyQt5.QtCore import QTimer
2525

26-
catalog = i18nCatalog("cura")
26+
# catalog = i18nCatalog("cura")
2727

28+
catalog = i18nCatalog("mksplugin")
2829

2930
class MachineConfig(MachineAction):
3031
def __init__(self, parent=None):
31-
super().__init__("MachineConfig", catalog.i18nc("@action", "MKS WIFI"))
32+
super().__init__("MachineConfig", catalog.i18nc("@action", "MKS WiFi Connection"))
3233
self._qml_url = os.path.join("qml", "MachineConfig.qml")
3334
ContainerRegistry.getInstance().containerAdded.connect(self._onContainerAdded)
3435

SaveOutputDevice.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
from UM.OutputDevice.OutputDevice import OutputDevice
1717
from UM.i18n import i18nCatalog
1818

19-
catalog = i18nCatalog("uranium")
19+
# catalog = i18nCatalog("uranium")
20+
21+
catalog = i18nCatalog("mksplugin")
2022

2123
from . import utils
2224

@@ -26,13 +28,13 @@ def __init__(self):
2628
self.setName("save_with_screenshot")
2729
self.setPriority(2)
2830
self._preferences = Application.getInstance().getPreferences()
29-
button_name = "Save as TFT file"
30-
if Application.getInstance().getPreferences().getValue("general/language") == "zh_CN":
31-
button_name = "保存为TFT文件"
32-
else:
33-
button_name = "Save as TFT file"
34-
self.setShortDescription(catalog.i18nc("@action:button", button_name))
35-
self.setDescription(catalog.i18nc("@properties:tooltip", button_name))
31+
# button_name = "Save as TFT file"
32+
# if Application.getInstance().getPreferences().getValue("general/language") == "zh_CN":
33+
# button_name = "保存为TFT文件"
34+
# else:
35+
# button_name = "Save as TFT file"
36+
self.setShortDescription(catalog.i18nc("@action:button", "Save as TFT file"))
37+
self.setDescription(catalog.i18nc("@properties:tooltip", "Save as TFT file"))
3638
self.setIconName("save")
3739

3840
self._writing = False

0 commit comments

Comments
 (0)