本文整理汇总了Python中miro.gtcache.ngettext函数的典型用法代码示例。如果您正苦于以下问题:Python ngettext函数的具体用法?Python ngettext怎么用?Python ngettext使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ngettext函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_progress
def make_progress():
if self.cancelled:
self.gathered_media_files = []
self.finder = None
progress_label.set_text("")
return
try:
num_parsed, found = self.finder.next()
self.gathered_media_files = found
num_found = len(found)
num_files = ngettext("parsed %(count)s file",
"parsed %(count)s files",
num_parsed,
{"count": num_parsed})
num_media_files = ngettext("found %(count)s media file",
"found %(count)s media files",
num_found,
{"count": num_found})
progress_label.set_text(u"%s - %s" % (num_files,
num_media_files))
threads.call_on_ui_thread(make_progress)
except StopIteration:
handle_cancel_clicked(None)
self.finder = None
示例2: _update_full_section
def _update_full_section(self, downloads, items, autoqueued_count):
if self._search_text == '':
itemtext = ngettext("%(count)d Item",
"%(count)d Items",
items,
{"count": items})
downloadingtext = ngettext("%(count)d Downloading",
"%(count)d Downloading",
downloads,
{"count": downloads})
if autoqueued_count:
queuedtext = ngettext("%(count)d Download Queued Due To "
"Unplayed Items (See Settings)",
"%(count)d Downloads Queued Due To "
"Unplayed Items (See Settings)",
autoqueued_count,
{"count": autoqueued_count})
text = u"| %s" % itemtext
if downloads:
text = text + u" | %s" % downloadingtext
if autoqueued_count:
text = text + u" | %s" % queuedtext
else:
text = ngettext("%(count)d Item Matches Search",
"%(count)d Items Match Search",
items, {"count": items})
text = u"| %s" % text
self.full_section.set_info(text)
示例3: get_formatted_default_expiration
def get_formatted_default_expiration():
"""Returns the 'system' expiration delay as a formatted string
"""
expiration = float(app.config.get(prefs.EXPIRE_AFTER_X_DAYS))
formatted_expiration = u''
if expiration < 0:
formatted_expiration = _('never')
elif expiration < 1.0:
hours = int(expiration * 24.0)
formatted_expiration = ngettext("%(count)d hour ago",
"%(count)d hours ago",
hours,
{"count": hours})
elif expiration >= 1 and expiration < 30:
days = int(expiration)
formatted_expiration = ngettext("%(count)d day ago",
"%(count)d days ago",
days,
{"count": days})
elif expiration >= 30:
months = int(expiration / 30)
formatted_expiration = ngettext("%(count)d month ago",
"%(count)d months ago",
months,
{"count": months})
return formatted_expiration
示例4: test_ngettext
def test_ngettext(self):
# french uses singular for 0, 1 and plural for everything else.
self.assertEqual(gtcache.ngettext("%(count)d video found",
"%(count)d videos found", 0),
u'%(count)d vid\xe9o trouv\xe9e')
self.assertEqual(gtcache.ngettext("%(count)d video found",
"%(count)d videos found", 1),
u'%(count)d vid\xe9o trouv\xe9e')
self.assertEqual(gtcache.ngettext("%(count)d video found",
"%(count)d videos found", 2),
u'%(count)d vid\xe9os trouv\xe9es')
示例5: _build_progress_label
def _build_progress_label(self, num_found, num_parsed):
num_files = ngettext(
"Searched %(count)s file",
"Searched %(count)s files",
num_parsed,
{"count": num_parsed})
num_media_files = ngettext(
"found %(count)s media file",
"found %(count)s media files",
num_found,
{"count": num_found})
return u"%s - %s" % (num_files, num_media_files)
示例6: time_string
def time_string(secs):
if secs >= (60 * 60 * 24):
t_dy = secs * 1.0 / (60 * 60 * 24)
return ngettext('%(num).0f day', '%(num).0f days', int(t_dy),
{"num": t_dy})
if secs >= (60 * 60):
t_hr = secs * 1.0 / (60 * 60)
return ngettext('%(num).0f hr', '%(num).0f hrs', int(t_hr),
{"num": t_hr})
if secs >= 60:
t_min = secs * 1.0 / 60
return ngettext('%(num).0f min', '%(num).0f mins', int(t_min),
{"num": t_min})
return ngettext('%(num)d sec', '%(num)d secs', secs, {"num": secs})
示例7: _update_downloading_section
def _update_downloading_section(self, downloads):
if downloads > 0:
text = ngettext("%(count)d Downloading", "%(count)d Downloading", downloads, {"count": downloads})
self.downloading_section.set_header(text)
self.downloading_section.show()
else:
self.downloading_section.hide()
示例8: show_import_summary
def show_import_summary(self):
imported_feeds = len(self.result[0].get('feed', []))
ignored_feeds = len(self.result[1].get('feed', []))
title = _("OPML Import summary")
message = ngettext("Successfully imported %(count)d feed.",
"Successfully imported %(count)d feeds.",
imported_feeds,
{"count": imported_feeds})
if self.ignored_feeds > 0:
message += "\n"
message += ngettext("Skipped %(count)d feed already present.",
"Skipped %(count)d feeds already present.",
ignored_feeds,
{"count": ignored_feeds})
dialog = dialogs.MessageBoxDialog(title, message)
dialog.run()
示例9: make_search_progress
def make_search_progress(self):
if self.cancelled:
self.finder = None
return
try:
num_parsed, found = self.finder.next()
self.gathered_media_files = found
num_found = len(found)
num_files = ngettext("parsed %(count)s file",
"parsed %(count)s files",
num_parsed,
{"count": num_parsed})
num_media_files = ngettext("found %(count)s media file",
"found %(count)s media files",
num_found,
{"count": num_found})
self.progress_label.set_text(u"%s - %s" % (
num_files, num_media_files))
threads.call_on_ui_thread(self.make_search_progress)
except StopIteration:
num_found = len(self.gathered_media_files)
self.search_complete(
ngettext(
"found %(count)s media file",
"found %(count)s media files",
num_found,
{"count": num_found}))
self.finder = None
except Exception:
# this is here to get more data for bug #17422
logging.exception("exception thrown in make_search_progress")
# we want to clean up after this exception, too.
num_found = len(self.gathered_media_files)
self.search_complete(
ngettext(
"found %(count)s media file",
"found %(count)s media files",
num_found,
{"count": num_found}))
self.finder = None
示例10: _update_downloaded_section
def _update_downloaded_section(self, watchable):
if watchable > 0:
text = ngettext("%(count)d Item", "%(count)d Items", watchable, {"count": watchable})
text = u"| %s " % text
self.downloaded_section.set_info(text)
self.downloaded_section.show()
else:
self.downloaded_section.hide()
示例11: expiration_date_short
def expiration_date_short(exp_date):
offset = exp_date - datetime.datetime.now()
if offset.days > 0:
return ngettext("Expires: %(count)d day",
"Expires: %(count)d days",
offset.days,
{"count": offset.days})
elif offset.seconds > 3600:
return ngettext("Expires: %(count)d hour",
"Expires: %(count)d hours",
math.ceil(offset.seconds/3600.0),
{"count": math.ceil(offset.seconds/3600.0)})
else:
return ngettext("Expires: %(count)d minute",
"Expires: %(count)d minutes",
math.ceil(offset.seconds/60.0),
{"count": math.ceil(offset.seconds/60.0)})
示例12: test_ngettext_counts
def test_ngettext_counts(self):
# test that it always truncates the count arg and we
# should always get the singular form.
self.assertEqual(gtcache.ngettext("%(count)d video found",
"%(count)d videos found", 1.0),
u'%(count)d vid\xe9o trouv\xe9e')
self.assertEqual(gtcache.ngettext("%(count)d video found",
"%(count)d videos found", 1.5),
u'%(count)d vid\xe9o trouv\xe9e')
self.assertEqual(gtcache.ngettext("%(count)d video found",
"%(count)d videos found", 1.9),
u'%(count)d vid\xe9o trouv\xe9e')
self.assertEqual(gtcache.ngettext("%(count)d video found",
"%(count)d videos found", 2.0),
u'%(count)d vid\xe9os trouv\xe9es')
self.assertEqual(gtcache.ngettext("%(count)d video found",
"%(count)d videos found", 2.5),
u'%(count)d vid\xe9os trouv\xe9es')
self.assertEqual(gtcache.ngettext("%(count)d video found",
"%(count)d videos found", 2.9),
u'%(count)d vid\xe9os trouv\xe9es')
self.assertEqual(gtcache.ngettext("%(count)d video found",
"%(count)d videos found", int(2.5)),
u'%(count)d vid\xe9os trouv\xe9es')
示例13: current_sync_information
def current_sync_information(self, video_count, audio_count):
if video_count == 0 and audio_count == 0:
self.sync_state.set_text(_('Up to date'))
self.sync_button.disable()
else:
self.sync_button.enable()
counts = []
if video_count:
counts.append(ngettext('%(count)d video file',
'%(count)d video files',
video_count,
{"count": video_count}))
if audio_count:
counts.append(ngettext('%(count)d audio file',
'%(count)d audio files',
audio_count,
{"count": audio_count}))
self.sync_state.set_text('\n'.join(counts))
示例14: expiration_date_short
def expiration_date_short(exp_date):
offset = exp_date - datetime.datetime.now()
if offset.days > 0:
return ngettext("Expires: %(count)d day",
"Expires: %(count)d days",
offset.days,
{"count": offset.days})
elif offset.seconds > 3600:
hours = int(round(offset.seconds / 3600.0))
return ngettext("Expires: %(count)d hour",
"Expires: %(count)d hours",
hours,
{"count": hours})
else:
minutes = int(round(offset.seconds / 60.0))
return ngettext("Expires: %(count)d minute",
"Expires: %(count)d minutes",
minutes,
{"count": minutes})
示例15: test_ngettext_values
def test_ngettext_values(self):
# try the bad translation with no values
self.assertEqual(gtcache.ngettext("bad %(count)d video found",
"bad %(count)d videos found", 0),
u'bad %(count) vid\xe9o trouv\xe9e')
# try the bad translation with values
self.assertEqual(gtcache.ngettext("bad %(count)d video found",
"bad %(count)d videos found", 0,
{"count": 0}),
u'bad 0 videos found')
self.assertEqual(gtcache.ngettext("bad %(count)d video found",
"bad %(count)d videos found", 1,
{"count": 1}),
u'bad 1 video found')
self.assertEqual(gtcache.ngettext("bad %(count)d video found",
"bad %(count)d videos found", 2,
{"count": 2}),
u'bad 2 videos found')