def TranslateTXT(txt):
t = gettext.dgettext(PluginLanguageDomain, txt)
if t == txt:
t = gettext.gettext(txt)
return t
python类dgettext()的实例源码
def addItems(self, list, parentNode):
for x in parentNode:
if not x.tag:
continue
if x.tag == 'item':
item_level = int(x.get("level", 0))
if not self.onNotifiers:
self.onNotifiers.append(self.levelChanged)
self.onClose.append(self.removeNotifier)
if item_level > config.usage.setup_level.index:
continue
requires = x.get("requires")
if requires and requires.startswith('config.'):
item = eval(requires or "")
if item.value and not item.value == "0":
SystemInfo[requires] = True
else:
SystemInfo[requires] = False
if requires and not SystemInfo.get(requires, False):
continue
if self.PluginLanguageDomain:
item_text = dgettext(self.PluginLanguageDomain, x.get("text", "??").encode("UTF-8"))
item_description = dgettext(self.PluginLanguageDomain, x.get("description", " ").encode("UTF-8"))
else:
item_text = _(x.get("text", "??").encode("UTF-8"))
item_description = _(x.get("description", " ").encode("UTF-8"))
item_text = item_text.replace("%s %s","%s %s" % (getMachineBrand(), getMachineName()))
item_description = item_description.replace("%s %s","%s %s" % (getMachineBrand(), getMachineName()))
b = eval(x.text or "")
if b == "":
continue
#add to configlist
item = b
# the first b is the item itself, ignored by the configList.
# the second one is converted to string.
if not isinstance(item, ConfigNothing):
list.append((item_text, item, item_description))
def __init__(self, session, retvalue=1, timeout=-1, default_yes = True):
self.retval = retvalue
self.ptsmainloopvalue = retvalue
recordings = session.nav.getRecordings()
jobs = []
for job in job_manager.getPendingJobs():
if job.name != dgettext('vix', 'SoftcamCheck'):
jobs.append(job)
inTimeshift = Screens.InfoBar.InfoBar and Screens.InfoBar.InfoBar.instance and Screens.InfoBar.InfoBar.ptsGetTimeshiftStatus(Screens.InfoBar.InfoBar.instance)
self.connected = False
reason = ""
next_rec_time = -1
if not recordings:
next_rec_time = session.nav.RecordTimer.getNextRecordingTime()
if len(jobs):
reason = (ngettext("%d job is running in the background!", "%d jobs are running in the background!", len(jobs)) % len(jobs)) + '\n'
if len(jobs) == 1:
job = jobs[0]
reason += "%s: %s (%d%%)\n" % (job.getStatustext(), job.name, int(100*job.progress/float(job.end)))
else:
reason += (_("%d jobs are running in the background!") % len(jobs)) + '\n'
if inTimeshift:
reason = _("You seem to be in timeshift!") + '\n'
if recordings or (next_rec_time > 0 and (next_rec_time - time()) < 360):
default_yes = False
reason = _("Recording(s) are in progress or coming up in few seconds!") + '\n'
if reason and inStandby:
session.nav.record_event.append(self.getRecordEvent)
self.skinName = ""
elif reason and not inStandby:
text = { 1: _("Really shutdown now?"),
2: _("Really reboot now?"),
3: _("Really restart now?"),
4: _("Really upgrade the frontprocessor and reboot now?"),
42: _("Really upgrade your %s %s and reboot now?") % (getMachineBrand(), getMachineName()),
43: _("Really reflash your %s %s and reboot now?") % (getMachineBrand(), getMachineName()) }.get(retvalue)
if text:
MessageBox.__init__(self, session, reason+text, type = MessageBox.TYPE_YESNO, timeout = timeout, default = default_yes)
self.skinName = "MessageBoxSimple"
session.nav.record_event.append(self.getRecordEvent)
self.connected = True
self.onShow.append(self.__onShow)
self.onHide.append(self.__onHide)
return
self.skin = """<screen position="1310,0" size="0,0"/>"""
Screen.__init__(self, session)
self.close(True)
def addItems(self, list, parentNode):
for x in parentNode:
if not x.tag:
continue
if x.tag == 'item':
item_level = int(x.get("level", 0))
if not self.levelChanged in config.usage.setup_level.notifiers:
config.usage.setup_level.notifiers.append(self.levelChanged)
self.onClose.append(self.removeNotifier)
if item_level > config.usage.setup_level.index:
continue
requires = x.get("requires")
if requires and requires.startswith('config.'):
item = eval(requires or "")
if item.value and not item.value == "0":
SystemInfo[requires] = True
else:
SystemInfo[requires] = False
if requires and not SystemInfo.get(requires, False):
continue
if self.PluginLanguageDomain:
item_text = dgettext(self.PluginLanguageDomain, x.get("text", "??").encode("UTF-8"))
item_description = dgettext(self.PluginLanguageDomain, x.get("description", " ").encode("UTF-8"))
else:
item_text = _(x.get("text", "??").encode("UTF-8"))
item_description = _(x.get("description", " ").encode("UTF-8"))
item_text = item_text.replace("%s %s","%s %s" % (getMachineBrand(), getMachineName()))
item_description = item_description.replace("%s %s","%s %s" % (getMachineBrand(), getMachineName()))
b = eval(x.text or "")
if b == "":
continue
#add to configlist
item = b
# the first b is the item itself, ignored by the configList.
# the second one is converted to string.
if not isinstance(item, ConfigNothing):
list.append((item_text, item, item_description))