add i18n to PLC status
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Thu, 01 Dec 2016 18:30:34 +0300
changeset 1587 b1be42401522
parent 1586 e17406dd4f06
child 1588 9277d3174744
add i18n to PLC status

Extra strings are added to the code to make mki18n.py to find these
strings in source files and put them into i18n/messages.pot.
ProjectController.py
--- a/ProjectController.py	Thu Dec 01 16:59:16 2016 +0300
+++ b/ProjectController.py	Thu Dec 01 18:30:34 2016 +0300
@@ -1269,17 +1269,27 @@
                 updated = True
                 self.AppFrame.RefreshStatusToolBar()
                 if status == "Disconnected":
-                    self.AppFrame.ConnectionStatusBar.SetStatusText(_(status), 1)
+                    self.AppFrame.ConnectionStatusBar.SetStatusText(self.GetTextStatus(status), 1)
                     self.AppFrame.ConnectionStatusBar.SetStatusText('', 2)
                 else:
                     self.AppFrame.ConnectionStatusBar.SetStatusText(
                         _("Connected to URI: %s") % self.BeremizRoot.getURI_location().strip(), 1)
-                    self.AppFrame.ConnectionStatusBar.SetStatusText(_(status), 2)
+                    self.AppFrame.ConnectionStatusBar.SetStatusText(self.GetTextStatus(status), 2)
         return updated
 
+    def GetTextStatus(self, status):
+        msgs = {
+            "Started":      _("Started"),
+            "Stopped":      _("Stopped"),
+            "Empty":        _("Empty"),
+            "Broken":       _("Broken"),
+            "Disconnected": _("Disconnected")
+            }
+        return msgs.get(status, status)
+    
     def ShowPLCProgress(self, status = "", progress = 0):
         self.AppFrame.ProgressStatusBar.Show()
-        self.AppFrame.ConnectionStatusBar.SetStatusText(status, 1)
+        self.AppFrame.ConnectionStatusBar.SetStatusText(self.GetTextStatus(status), 1)
         self.AppFrame.ProgressStatusBar.SetValue(progress)
 
     def HidePLCProgress(self):