[pitivi] medialibrary: Show the amount of errors with ngettext in warning_infobar
- From: Jean-François Fortin Tam <jfft src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] medialibrary: Show the amount of errors with ngettext in warning_infobar
- Date: Sat, 21 Dec 2013 17:45:48 +0000 (UTC)
commit e76531494f930e520e87b112d4820d405d79af92
Author: Jean-François Fortin Tam <nekohayo gmail com>
Date: Wed Dec 18 00:11:13 2013 -0500
medialibrary: Show the amount of errors with ngettext in warning_infobar
Until now we just said "Errors occurred while importing", so we might as well
say the exact number to let the user know how many clips failed to import.
This is also demonstrates Python's new standard way of formatting strings.
pitivi/medialibrary.py | 21 +++++++++++++--------
1 files changed, 13 insertions(+), 8 deletions(-)
---
diff --git a/pitivi/medialibrary.py b/pitivi/medialibrary.py
index 0545118..ca05377 100644
--- a/pitivi/medialibrary.py
+++ b/pitivi/medialibrary.py
@@ -35,7 +35,7 @@ import os
import time
from urllib import unquote
-from gettext import gettext as _
+from gettext import ngettext, gettext as _
from hashlib import md5
from gi.repository.GstPbutils import DiscovererVideoInfo
@@ -635,13 +635,18 @@ class MediaLibraryWidget(Gtk.VBox, Loggable):
self.flush_pending_rows()
self._progressbar.hide()
if self._errors:
- if len(self._errors) > 1:
- self._warning_label.set_text(_("Errors occurred while importing."))
- self._view_error_button.set_label(_("View errors"))
- else:
- self._warning_label.set_text(_("An error occurred while importing."))
- self._view_error_button.set_label(_("View error"))
-
+ errors_amount = len(self._errors)
+ btn_text = ngettext("View error", "View errors", errors_amount)
+ # Translators: {0:d} is just like %d (integer number variable)
+ text = ngettext("An error occurred while importing.",
+ "{0:d} errors occurred while importing.",
+ errors_amount)
+ # Do the {0:d} (aka "%d") substitution using "format" instead of %,
+ # avoiding tracebacks as %d would be missing in the singular form:
+ text = text.format(errors_amount)
+
+ self._view_error_button.set_label(btn_text)
+ self._warning_label.set_text(text)
self._import_warning_infobar.show_all()
## Error Dialog Box callbacks
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]