本文整理汇总了Python中quodlibet.ngettext函数的典型用法代码示例。如果您正苦于以下问题:Python ngettext函数的具体用法?Python ngettext怎么用?Python ngettext使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ngettext函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _album
def _album(self, songs, box):
text = []
discs = {}
for song in songs:
try:
discs[song("~#disc")] = int(
song["tracknumber"].split("/")[1])
except (AttributeError, ValueError, IndexError, KeyError):
discs[song("~#disc")] = max([
song("~#track", discs.get(song("~#disc"), 0))])
tracks = sum(discs.values())
discs = len(discs)
length = sum([song.get("~#length", 0) for song in songs])
if tracks == 0 or tracks < len(songs):
tracks = len(songs)
parts = []
if discs > 1:
parts.append(
ngettext("%d disc", "%d discs", discs) % discs)
parts.append(
ngettext("%d track", "%d tracks", tracks) % tracks)
if tracks != len(songs):
parts.append(ngettext("%d selected", "%d selected",
len(songs)) % len(songs))
text.append(", ".join(parts))
text.append(util.format_time_preferred(length))
if "location" in song:
text.append(util.escape(song["location"]))
if "organization" in song or "labelid" in song:
t = util.escape(song.comma("~organization~labelid"))
text.append(t)
if "producer" in song:
text.append(_("Produced by %s") % (
util.escape(song.comma("producer"))))
w = Label("")
w.set_ellipsize(Pango.EllipsizeMode.END)
w.set_markup("\n".join(text))
hb = Gtk.HBox(spacing=12)
cover = CoverImage()
cover.set_property('no-show-all', True)
hb.pack_start(cover, False, True, 0)
def show_cover(cover, success):
if success:
cover.show()
cover.disconnect(signal_id)
signal_id = cover.connect('cover-visible', show_cover)
cover.set_song(song)
hb.pack_start(w, True, True, 0)
box.pack_start(hb, False, False, 0)
开发者ID:urielz,项目名称:quodlibet,代码行数:59,代码来源:information.py
示例2: _album
def _album(self, songs, box):
albums, noalbum = _sort_albums(songs)
def format(args):
date, song, album = args
markup = "<big><i>%s</i></big>" % util.escape(album)
return "%s (%s)" % (markup, date[:4]) if date else markup
get_cover = app.cover_manager.get_cover
covers = [(a, get_cover(s), s) for d, s, a in albums]
albums = [format(a) for a in albums]
if noalbum:
albums.append(ngettext("%d song with no album",
"%d songs with no album", noalbum) % noalbum)
l = Label(markup="\n".join(albums), ellipsize=True)
box.pack_start(Frame(_("Selected Discography"), l), False, False, 0)
covers = [ac for ac in covers if bool(ac[1])]
t = Gtk.Table(n_rows=4, n_columns=(len(covers) // 4) + 1)
t.set_col_spacings(12)
t.set_row_spacings(12)
added = set()
for i, (album, cover, song) in enumerate(covers):
if cover.name in added:
continue
cov = ReactiveCoverImage(song=song, tooltip=album)
c = i % 4
r = i // 4
t.attach(cov, c, c + 1, r, r + 1,
xoptions=Gtk.AttachOptions.EXPAND, yoptions=0)
added.add(cover.name)
box.pack_start(t, True, True, 0)
开发者ID:LudoBike,项目名称:quodlibet,代码行数:32,代码来源:information.py
示例3: plugin_songs
def plugin_songs(self, songs):
desc = ngettext("%d song", "%d songs", len(songs)) % len(songs)
win = ConsoleWindow(create_console(songs), title=desc)
win.set_icon_name(self.PLUGIN_ICON)
win.set_title(_("{plugin_name} for {songs} ({app})").format(
plugin_name=self.PLUGIN_NAME, songs=desc, app=app.name))
win.show_all()
开发者ID:zsau,项目名称:quodlibet,代码行数:7,代码来源:console.py
示例4: _album
def _album(self, songs, box):
text = []
discs = {}
for song in songs:
try:
discs[song("~#disc")] = int(
song["tracknumber"].split("/")[1])
except (AttributeError, ValueError, IndexError, KeyError):
discs[song("~#disc")] = max([
song("~#track", discs.get(song("~#disc"), 0))])
tracks = sum(discs.values())
discs = len(discs)
length = sum([song.get("~#length", 0) for song in songs])
if tracks == 0 or tracks < len(songs):
tracks = len(songs)
parts = []
if discs > 1:
parts.append(
ngettext("%d disc", "%d discs", discs) % discs)
parts.append(
ngettext("%d track", "%d tracks", tracks) % tracks)
if tracks != len(songs):
parts.append(ngettext("%d selected", "%d selected",
len(songs)) % len(songs))
text.append(", ".join(parts))
text.append("(%s)" % util.format_time_preferred(length))
if "location" in song:
text.append(util.escape(song["location"]))
if "organization" in song or "labelid" in song:
t = util.escape(song.comma("~organization~labelid"))
text.append(t)
if "producer" in song:
text.append(_("Produced by %s") % (
util.escape(song.comma("producer"))))
w = Label(markup="\n".join(text), ellipsize=True)
hb = Gtk.HBox(spacing=12)
hb.pack_start(w, True, True, 0)
hb.pack_start(ReactiveCoverImage(song=song), False, True, 0)
box.pack_start(hb, False, False, 0)
开发者ID:elfalem,项目名称:quodlibet,代码行数:47,代码来源:information.py
示例5: confirm_multi_album_invoke
def confirm_multi_album_invoke(parent, plugin_name, count):
"""Dialog to confirm invoking a plugin with X albums in case X is high"""
title = ngettext("Run the plugin \"%(name)s\" on %(count)d album?",
"Run the plugin \"%(name)s\" on %(count)d albums?",
count) % {"name": plugin_name, "count": count}
description = ""
ok_text = _("_Run Plugin")
prompt = ConfirmationPrompt(parent, title, description, ok_text).run()
return prompt == ConfirmationPrompt.RESPONSE_INVOKE
开发者ID:zsau,项目名称:quodlibet,代码行数:9,代码来源:songsmenu.py
示例6: __update_count
def __update_count(self, model, path, lab):
if len(model) == 0:
text = ""
else:
time = sum([row[0].get("~#length", 0) for row in model])
text = ngettext("%(count)d song (%(time)s)",
"%(count)d songs (%(time)s)",
len(model)) % {
"count": len(model), "time": format_time_preferred(time)}
lab.set_text(text)
开发者ID:elfalem,项目名称:quodlibet,代码行数:10,代码来源:queue.py
示例7: suggested_name_for
def suggested_name_for(cls, songs):
if len(songs) == 1:
title = songs[0].comma("title")
else:
title = ngettext(
"%(title)s and %(count)d more",
"%(title)s and %(count)d more",
len(songs) - 1) % (
{'title': songs[0].comma("title"),
'count': len(songs) - 1})
return title
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:11,代码来源:collection.py
示例8: confirm_multi_playlist_invoke
def confirm_multi_playlist_invoke(parent, plugin_name, count):
"""Dialog to confirm invoking a plugin with X playlists
in case X is high
"""
params = {"name": plugin_name, "count": format_int_locale(count)}
title = ngettext("Run the plugin \"%(name)s\" on %(count)s playlist?",
"Run the plugin \"%(name)s\" on %(count)s playlists?",
count) % params
description = ""
ok_text = _("_Run Plugin")
prompt = ConfirmationPrompt(parent, title, description, ok_text).run()
return prompt == ConfirmationPrompt.RESPONSE_INVOKE
开发者ID:LudoBike,项目名称:quodlibet,代码行数:12,代码来源:playlist.py
示例9: __init__
def __init__(self, parent, plugin_name, count):
title = ngettext("Run the plugin \"%(name)s\" on %(count)d album?",
"Run the plugin \"%(name)s\" on %(count)d albums?",
count) % {'name': plugin_name, 'count': count}
super(ConfirmMultiAlbumInvoke, self).__init__(
get_top_parent(parent),
title, "",
buttons=Gtk.ButtonsType.NONE)
self.add_button(_("_Cancel"), Gtk.ResponseType.CANCEL)
self.add_icon_button(_("_Run Plugin"), Icons.SYSTEM_RUN,
self.RESPONSE_INVOKE)
self.set_default_response(Gtk.ResponseType.CANCEL)
开发者ID:elfalem,项目名称:quodlibet,代码行数:14,代码来源:songsmenu.py
示例10: __init__
def __init__(self, parent, playlist, songs):
desc = ngettext("What do you want to do with that %d song?",
"What do you want to do with those %d songs?",
len(songs)) % len(songs)
title = _("Confirm action for playlist \"%s\"") % playlist.name
super(ConfirmMultipleSongsAction, self).__init__(
Gtk.MessageType.QUESTION, parent, title, desc,
Gtk.ButtonsType.NONE)
self.add_button(_("_Cancel"), Gtk.ResponseType.CANCEL)
self.add_icon_button(_("_Add"), Icons.LIST_ADD, self.ADD)
self.add_icon_button(_("_Remove"), Icons.LIST_REMOVE, self.REMOVE)
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:14,代码来源:menu.py
示例11: confirm_song_removal_invoke
def confirm_song_removal_invoke(parent, songs):
songs = set(songs)
if not songs:
return True
count = len(songs)
song = next(iter(songs))
title = (ngettext("Remove track: \"%%(title)s\" from library?",
"Remove %(count)d tracks from library?",
count) % {'count': count}) % {
'title': song('title') or song('~basename')}
return ConfirmationPrompt.RESPONSE_INVOKE == ConfirmationPrompt(
parent, title, "", _("Remove from Library")).run()
开发者ID:zsau,项目名称:quodlibet,代码行数:14,代码来源:songsmenu.py
示例12: __init__
def __init__(self, parent, playlist, count):
title = ngettext("Are you sure you want to remove %d duplicate song?",
"Are you sure you want to remove %d duplicate songs?",
count) % count
description = (_("The duplicate songs will be removed "
"from the playlist '%s'.") % playlist.name)
super(ConfirmRemoveDuplicatesDialog, self).__init__(
Gtk.MessageType.WARNING, parent, title, description,
Gtk.ButtonsType.NONE)
self.add_button(_("_Cancel"), Gtk.ResponseType.CANCEL)
self.add_icon_button(_("_Remove"), Icons.LIST_REMOVE,
Gtk.ResponseType.YES)
开发者ID:LudoBike,项目名称:quodlibet,代码行数:14,代码来源:remove_duplicates.py
示例13: __on_changed
def __on_changed(self, widget, songs):
if songs:
if len(songs) == 1:
title = songs[0].comma("title")
else:
title = ngettext(
"%(title)s and %(count)d more",
"%(title)s and %(count)d more",
len(songs) - 1) % {'title': songs[0].comma("title"),
'count': len(songs) - 1}
self.set_title("%s - %s" % (title, _("Properties")))
else:
self.set_title(_("Properties"))
self.set_pending(None)
开发者ID:urielz,项目名称:quodlibet,代码行数:15,代码来源:properties.py
示例14: format_time_long
def format_time_long(time, limit=2):
"""Turn a time value in seconds into x hours, x minutes, etc.
`limit` limits the count of units used, so the result will be <= time.
0 means no limit.
"""
from quodlibet import ngettext
if time < 1:
return _("No time information")
cutoffs = [
(60, lambda n: ngettext("%d second", "%d seconds", n)),
(60, lambda n: ngettext("%d minute", "%d minutes", n)),
(24, lambda n: ngettext("%d hour", "%d hours", n)),
(365, lambda n: ngettext("%d day", "%d days", n)),
(None, lambda n: ngettext("%d year", "%d years", n)),
]
time_str = []
for divisor, gettext_partial in cutoffs:
if time < 1:
break
if divisor is None:
time, unit = 0, time
else:
time, unit = divmod(time, divisor)
if unit:
time_str.append(gettext_partial(unit) % unit)
time_str.reverse()
if limit:
time_str = time_str[:limit]
return ", ".join(time_str)
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:36,代码来源:__init__.py
示例15: __init__
def __init__(self, parent, plugin_name, count):
params = {"name": plugin_name, "count": format_int_locale(count)}
title = ngettext("Run the plugin \"%(name)s\" on %(count)s playlist?",
"Run the plugin \"%(name)s\" on %(count)s playlists?",
count) % params
super(ConfirmMultiPlaylistInvoke, self).__init__(
get_top_parent(parent),
title, "",
buttons=Gtk.ButtonsType.NONE)
self.add_button(_("_Cancel"), Gtk.ResponseType.CANCEL)
self.add_icon_button(
_("_Run Plugin"), Icons.SYSTEM_RUN, self.RESPONSE_INVOKE)
self.set_default_response(Gtk.ResponseType.CANCEL)
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:15,代码来源:playlist.py
示例16: cell_data
def cell_data(view, cell, model, iter_, data):
album = model.get_album(iter_)
if album is None:
text = "<b>%s</b>" % _("All Albums")
text += "\n" + ngettext("%d album", "%d albums",
len(model) - 1) % (len(model) - 1)
markup = text
else:
markup = self.display_pattern % album
if self.__last_render == markup:
return
self.__last_render = markup
cell.markup = markup
cell.set_property('markup', markup)
开发者ID:urielz,项目名称:quodlibet,代码行数:16,代码来源:main.py
示例17: __popup
def __popup(self, view, library):
albums = self.__get_selected_albums()
songs = self.__get_songs_from_albums(albums)
items = []
if self.__cover_column.get_visible():
num = len(albums)
button = MenuItem(
ngettext("Reload album _cover", "Reload album _covers", num),
Icons.VIEW_REFRESH)
button.connect('activate', self.__refresh_album, view)
items.append(button)
menu = SongsMenu(library, songs, items=[items])
menu.show_all()
return view.popup_menu(menu, 0, Gtk.get_current_event_time())
开发者ID:urielz,项目名称:quodlibet,代码行数:16,代码来源:main.py
示例18: _people
def _people(self, songs, box):
artists = set()
none = 0
for song in songs:
if "artist" in song:
artists.update(song.list("artist"))
else:
none += 1
artists = sorted(artists)
num_artists = len(artists)
if none:
artists.append(ngettext("%d song with no artist",
"%d songs with no artist", none) % none)
label = Label(markup=util.escape("\n".join(artists)), ellipsize=True)
frame = Frame("%s (%d)" % (util.capitalize(_("artists")), num_artists),
label)
box.pack_start(frame, False, False, 0)
开发者ID:elfalem,项目名称:quodlibet,代码行数:18,代码来源:information.py
示例19: __popup
def __popup(self, view, library):
albums = self.__get_selected_albums()
songs = self.__get_songs_from_albums(albums)
items = []
num = len(albums)
button = MenuItem(
ngettext("Reload album _cover", "Reload album _covers", num),
Icons.VIEW_REFRESH)
button.connect('activate', self.__refresh_album, view)
items.append(button)
menu = SongsMenu(library, songs, items=[items])
menu.show_all()
popup_menu_at_widget(menu, view,
Gdk.BUTTON_SECONDARY,
Gtk.get_current_event_time())
开发者ID:LudoBike,项目名称:quodlibet,代码行数:18,代码来源:main.py
示例20: _show_tooltip
def _show_tooltip(self, widget, x, y, keyboard_tip, tooltip):
w = self.scrollwin.get_hadjustment().get_value()
z = self.scrollwin.get_vadjustment().get_value()
path = widget.get_path_at_pos(int(x + w), int(y + z))
if path is None:
return False
model = widget.get_model()
iter = model.get_iter(path)
album = model.get_album(iter)
if album is None:
text = "<b>%s</b>" % _("All Albums")
text += "\n" + ngettext("%d album",
"%d albums", len(model) - 1) % (len(model) - 1)
markup = text
else:
markup = self.display_pattern % album
tooltip.set_markup(markup)
return True
开发者ID:urielz,项目名称:quodlibet,代码行数:18,代码来源:main.py
注:本文中的quodlibet.ngettext函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论