Fix title translation parsing in InputBox and LocationBox
authorTaapat <taapat@gmail.com>
Sat, 22 Aug 2015 12:57:47 +0000 (15:57 +0300)
committerTaapat <taapat@gmail.com>
Sat, 22 Aug 2015 12:57:47 +0000 (15:57 +0300)
We can not use the gettext in function parameter, so the default title translation does not work and gettext should be used twice. Use gettext only once, when set the text. This allows also always specify the text that will be parsed when creating pot file.

lib/python/Screens/InputBox.py
lib/python/Screens/LocationBox.py

index 12cc96b..7cabaf3 100644 (file)
@@ -9,12 +9,14 @@ from Tools.Notifications import AddPopup
 from time import time
 
 class InputBox(Screen):
-       def __init__(self, session, title = "", windowTitle = "Input", useableChars = None, **kwargs):
+       def __init__(self, session, title = "", windowTitle = None, useableChars = None, **kwargs):
                Screen.__init__(self, session)
 
                self["text"] = Label(title)
                self["input"] = Input(**kwargs)
-               self.onShown.append(boundFunction(self.setTitle, _(windowTitle)))
+               if windowTitle is None:
+                       windowTitle = _("Input")
+               self.onShown.append(boundFunction(self.setTitle, windowTitle))
                if useableChars is not None:
                        self["input"].setUseableChars(useableChars)
 
index 61ae482..a9a722e 100644 (file)
@@ -50,7 +50,7 @@ class LocationBox(Screen, NumericalTextInput, HelpableScreen):
                        <widget name="key_blue" position="405,415" zPosition="2" size="135,40" halign="center" valign="center" font="Regular;22" transparent="1" shadowColor="black" shadowOffset="-1,-1" />
                </screen>"""
 
-       def __init__(self, session, text = "", filename = "", currDir = None, bookmarks = None, userMode = False, windowTitle = "Select location", minFree = None, autoAdd = False, editDir = False, inhibitDirs = [], inhibitMounts = []):
+       def __init__(self, session, text = "", filename = "", currDir = None, bookmarks = None, userMode = False, windowTitle = None, minFree = None, autoAdd = False, editDir = False, inhibitDirs = [], inhibitMounts = []):
                # Init parents
                Screen.__init__(self, session)
                NumericalTextInput.__init__(self, handleTimeout = False)
@@ -165,8 +165,10 @@ class LocationBox(Screen, NumericalTextInput, HelpableScreen):
                })
 
                # Run some functions when shown
+               if windowTitle is None:
+                       windowTitle = _("Select location")
                self.onShown.extend((
-                       boundFunction(self.setTitle, _(windowTitle)),
+                       boundFunction(self.setTitle, windowTitle),
                        self.updateTarget,
                        self.showHideRename,
                ))