From 1f7c19f5353cbe4ddfc0232a0bed72868a5ab6fb Mon Sep 17 00:00:00 2001 From: Soren Bjornstad Date: Sun, 9 Sep 2012 17:07:47 -0500 Subject: [PATCH] added pluralization in a number of spots --- anki/importing/anki2.py | 3 ++- anki/importing/mnemo.py | 3 ++- anki/importing/noteimp.py | 7 +++++-- anki/importing/supermemo_xml.py | 3 ++- anki/stats.py | 6 +++--- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/anki/importing/anki2.py b/anki/importing/anki2.py index aec64c737..f84a10c19 100644 --- a/anki/importing/anki2.py +++ b/anki/importing/anki2.py @@ -6,6 +6,7 @@ from anki import Collection from anki.utils import intTime from anki.importing.base import Importer from anki.lang import _ +from anki.lang import ngettext # # Import a .anki2 file into the current collection. Used for migration from @@ -254,7 +255,7 @@ class Anki2Importer(Importer): insert or ignore into cards values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)""", cards) self.dst.db.executemany(""" insert or ignore into revlog values (?,?,?,?,?,?,?,?,?)""", revlog) - self.log.append(_("%d cards imported.") % cnt) + self.log.append(ngettext("%d card imported.", "%d cards imported.", cnt) % cnt) # Media ###################################################################### diff --git a/anki/importing/mnemo.py b/anki/importing/mnemo.py index e94f43d5c..5f2d6b2de 100644 --- a/anki/importing/mnemo.py +++ b/anki/importing/mnemo.py @@ -9,6 +9,7 @@ from anki.importing.noteimp import NoteImporter, ForeignNote, ForeignCard from anki.utils import checksum, base91 from anki.stdmodels import addBasicModel from anki.lang import _ +from anki.lang import ngettext class MnemosyneImporter(NoteImporter): @@ -83,7 +84,7 @@ acq_reps+ret_reps, lapses from cards"""): total += self.total self._addVocabulary(vocabulary) self.total += total - self.log.append(_("%d notes imported.") % self.total) + self.log.append(ngettext("%d note imported.", "%d notes imported.", self.total) % self.total) def fields(self): return self._fields diff --git a/anki/importing/noteimp.py b/anki/importing/noteimp.py index 5517b3a2d..6c8254f7b 100644 --- a/anki/importing/noteimp.py +++ b/anki/importing/noteimp.py @@ -8,6 +8,7 @@ from anki.utils import fieldChecksum, ids2str, guid64, timestampID, \ joinFields, intTime, splitFields from anki.errors import * from anki.importing.base import Importer +from anki.lang import ngettext # Stores a list of fields, tags and deck ###################################################################### @@ -150,8 +151,10 @@ class NoteImporter(Importer): # apply scheduling updates self.updateCards() # make sure to update sflds, etc - self.log.append(_("%(a)d notes added, %(b)d notes updated.") % - dict(a=len(new), b=self.updateCount)) + + part1 = ngettext("%d note added", "%d notes added", len(new)) % len(new) + part2 = ngettext("%d note updated", "%d notes updated", self.updateCount) % self.updateCount + self.log.append("%s, %s." % (part1, part2)) self.total = len(self._ids) def newData(self, n): diff --git a/anki/importing/supermemo_xml.py b/anki/importing/supermemo_xml.py index bdacc4080..f88d66068 100644 --- a/anki/importing/supermemo_xml.py +++ b/anki/importing/supermemo_xml.py @@ -7,6 +7,7 @@ import sys from anki.stdmodels import addBasicModel from anki.importing.noteimp import NoteImporter, ForeignNote, ForeignCard from anki.lang import _ +from anki.lang import ngettext from anki.errors import * from xml.dom import minidom, Node @@ -214,7 +215,7 @@ class SupermemoXmlImporter(NoteImporter): # Return imported cards self.total = len(self.notes) - self.log.append(_("%d cards imported.") % self.total) + self.log.append(ngettext("%d card imported.", "%d cards imported.", self.total) % self.total) return self.notes def fields(self): diff --git a/anki/stats.py b/anki/stats.py index 4dbd8a123..ea43284b3 100644 --- a/anki/stats.py +++ b/anki/stats.py @@ -169,7 +169,7 @@ h1 { margin-bottom: 0; margin-top: 1em; } def _dueInfo(self, tot, num): i = [] - self._line(i, _("Total"), _("%d reviews") % tot) + self._line(i, _("Total"), ngettext("%d review", "%d reviews", tot) % tot) self._line(i, _("Average"), self._avgDay( tot, num, _("reviews"))) return self._lineTbl(i) @@ -289,8 +289,8 @@ group by day order by day""" % (self._limit(), lim), if total and tot: self._line( i, _("Average answer time"), - _("%(a)0.1fs (%(b)d cards/minute)") % dict( - a=(tot*60)/total, b=(total / float(tot)))) + ngettext("%0.1fs (%d card/minute)", "%0.1fs (%d cards/minute)", \ + (total / float(tot))) % ((tot*60)/total, total / float(tot)) ) return self._lineTbl(i), int(tot) def _splitRepData(self, data, spec):