Skip to content

Commit

Permalink
Replace unggettext with ngettext
Browse files Browse the repository at this point in the history
  • Loading branch information
samj1912 committed Apr 7, 2017
1 parent a1e130e commit c04237c
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions picard/album.py
Expand Up @@ -542,10 +542,10 @@ def column(self, column):

number_of_images = len(metadata.images)
if getattr(metadata, 'has_common_images', True):
text += ungettext("; %i image", "; %i images",
text += ngettext("; %i image", "; %i images",
number_of_images) % number_of_images
else:
text += ungettext("; %i image not in all tracks", "; %i different images among tracks",
text += ngettext("; %i image not in all tracks", "; %i different images among tracks",
number_of_images) % number_of_images
return text + ')'
else:
Expand Down
4 changes: 2 additions & 2 deletions picard/collection.py
Expand Up @@ -64,7 +64,7 @@ def _add_finished(self, ids, callback, document, reply, error):
}
log.debug('Added %(count)i releases to collection "%(name)s"' % mparms)
self.tagger.window.set_statusbar_message(
ungettext('Added %(count)i release to collection "%(name)s"',
ngettext('Added %(count)i release to collection "%(name)s"',
'Added %(count)i releases to collection "%(name)s"',
count),
mparms,
Expand All @@ -86,7 +86,7 @@ def _remove_finished(self, ids, callback, document, reply, error):
log.debug('Removed %(count)i releases from collection "%(name)s"' %
mparms)
self.tagger.window.set_statusbar_message(
ungettext('Removed %(count)i release from collection "%(name)s"',
ngettext('Removed %(count)i release from collection "%(name)s"',
'Removed %(count)i releases from collection "%(name)s"',
count),
mparms,
Expand Down
8 changes: 4 additions & 4 deletions picard/i18n.py
Expand Up @@ -70,7 +70,7 @@ def setup_gettext(localedir, ui_language=None, logger=None):
logger("Loading gettext translation, localedir=%r", localedir)
trans = gettext.translation("picard", localedir)
trans.install(True)
_ungettext = trans.ungettext
_ngettext = trans.ngettext
logger("Loading gettext translation (picard-countries), localedir=%r", localedir)
trans_countries = gettext.translation("picard-countries", localedir)
_ugettext_countries = trans_countries.ugettext
Expand All @@ -81,7 +81,7 @@ def setup_gettext(localedir, ui_language=None, logger=None):
logger(e)
builtins.__dict__['_'] = lambda a: a

def _ungettext(a, b, c):
def _ngettext(a, b, c):
if c == 1:
return a
else:
Expand All @@ -93,13 +93,13 @@ def _ugettext_countries(msg):
def _ugettext_attributes(msg):
return msg

builtins.__dict__['ungettext'] = _ungettext
builtins.__dict__['ngettext'] = _ngettext
builtins.__dict__['ugettext_countries'] = _ugettext_countries
builtins.__dict__['ugettext_attributes'] = _ugettext_attributes

logger("_ = %r", _)
logger("N_ = %r", N_)
logger("ungettext = %r", ungettext)
logger("ngettext = %r", ngettext)
logger("ugettext_countries = %r", ugettext_countries)
logger("ugettext_attributes = %r", ugettext_attributes)

Expand Down
4 changes: 2 additions & 2 deletions picard/tagger.py
Expand Up @@ -405,7 +405,7 @@ def get_files():
log.debug("Adding %(count)d files from '%(directory)r'" %
mparms)
self.window.set_statusbar_message(
ungettext(
ngettext(
"Adding %(count)d file from '%(directory)s' ...",
"Adding %(count)d files from '%(directory)s' ...",
number_of_files),
Expand Down Expand Up @@ -438,7 +438,7 @@ def _add_directory_non_recursive(self, path):
log.debug("Adding %(count)d files from '%(directory)r'" %
mparms)
self.window.set_statusbar_message(
ungettext(
ngettext(
"Adding %(count)d file from '%(directory)s' ...",
"Adding %(count)d files from '%(directory)s' ...",
number_of_files),
Expand Down
2 changes: 1 addition & 1 deletion picard/ui/collectionmenu.py
Expand Up @@ -83,4 +83,4 @@ def updateText(self):

def label(self):
c = self.collection
return ungettext("%s (%i release)", "%s (%i releases)", c.size) % (c.name, c.size)
return ngettext("%s (%i release)", "%s (%i releases)", c.size) % (c.name, c.size)
2 changes: 1 addition & 1 deletion picard/ui/infodialog.py
Expand Up @@ -328,7 +328,7 @@ def _display_info_tab(self):
return

tabWidget.setTabText(tab_index, _("&Info"))
text = ungettext("%i file in this track", "%i files in this track",
text = ngettext("%i file in this track", "%i files in this track",
track.num_linked_files) % track.num_linked_files
info_files = [FileInfoDialog.format_file_info(file) for file in track.linked_files]
text += '<hr />' + '<hr />'.join(info_files)
Expand Down
2 changes: 1 addition & 1 deletion picard/ui/mainwindow.py
Expand Up @@ -163,7 +163,7 @@ def show_quit_confirmation(self):
msg.setWindowModality(QtCore.Qt.WindowModal)
msg.setWindowTitle(_(u"Unsaved Changes"))
msg.setText(_(u"Are you sure you want to quit Picard?"))
txt = ungettext(
txt = ngettext(
"There is %d unsaved file. Closing Picard will lose all unsaved changes.",
"There are %d unsaved files. Closing Picard will lose all unsaved changes.",
unsaved_files) % unsaved_files
Expand Down
6 changes: 3 additions & 3 deletions picard/ui/metadatabox.py
Expand Up @@ -81,15 +81,15 @@ def display_value(self, tag):
missing = self.parent.objects - count

if tag in self.different:
return (ungettext("(different across %d item)", "(different across %d items)", count) % count, True)
return (ngettext("(different across %d item)", "(different across %d items)", count) % count, True)
else:
if tag == "~length":
msg = format_time(self.get(tag, 0))
else:
msg = MULTI_VALUED_JOINER.join(self[tag])

if count > 0 and missing > 0:
return (msg + " " + (ungettext("(missing from %d item)", "(missing from %d items)", missing) % missing), True)
return (msg + " " + (ngettext("(missing from %d item)", "(missing from %d items)", missing) % missing), True)
else:
return (msg, False)

Expand Down Expand Up @@ -316,7 +316,7 @@ def contextMenuEvent(self, event):
remove_tag_action.setShortcut(self.remove_tag_shortcut.key())
menu.addAction(remove_tag_action)
if useorigs:
name = ungettext("Use Original Value", "Use Original Values", len(useorigs))
name = ngettext("Use Original Value", "Use Original Values", len(useorigs))
use_orig_value_action = QtWidgets.QAction(name, self.parent)
use_orig_value_action.triggered.connect(lambda: [f() for f in useorigs])
menu.addAction(use_orig_value_action)
Expand Down

0 comments on commit c04237c

Please sign in to comment.