mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
commit
e4ed15e111
7 changed files with 32 additions and 18 deletions
|
@ -17,6 +17,7 @@ from anki.hooks import runHook, addHook, remHook
|
|||
from aqt.webview import AnkiWebView
|
||||
from aqt.toolbar import Toolbar
|
||||
from anki.consts import *
|
||||
from anki.lang import ngettext
|
||||
|
||||
COLOUR_SUSPENDED = "#FFFFB2"
|
||||
COLOUR_MARKED = "#D9B2E9"
|
||||
|
@ -1179,13 +1180,15 @@ update cards set usn=?, mod=?, did=? where odid=0 and id in """ + ids2str(
|
|||
self.mw.progress.start()
|
||||
res = self.mw.col.findDupes(fname, search)
|
||||
t = "<html><body>"
|
||||
t += _("Found %(a)d duplicates in %(b)d notes.") % dict(
|
||||
a=sum(len(r[1]) for r in res), b=len(res))
|
||||
part1 = ngettext("Found %d duplicate in", "Found %d duplicates in", \
|
||||
sum(len(r[1]) for r in res)) % sum(len(r[1]) for r in res)
|
||||
part2 = ngettext("%d note.", "%d notes.", len(res)) % len(res)
|
||||
t += "%s %s" % (part1, part2)
|
||||
t += "<p><ol>"
|
||||
for val, nids in res:
|
||||
t += '<li><a href="%s">%s</a>: %s</a>' % (
|
||||
"nid:" + ",".join(str(id) for id in nids),
|
||||
_("%d notes") % len(nids),
|
||||
ngettext("%d note", "%d notes", len(nids)) % len(nids),
|
||||
cgi.escape(val))
|
||||
t += "</ol>"
|
||||
t += "</body></html>"
|
||||
|
|
|
@ -10,6 +10,7 @@ import anki.js
|
|||
from anki.errors import DeckRenameError
|
||||
import aqt
|
||||
from anki.sound import clearAudioQueue
|
||||
from anki.lang import ngettext
|
||||
|
||||
class DeckBrowser(object):
|
||||
|
||||
|
@ -155,8 +156,8 @@ select count(), sum(time)/1000 from revlog
|
|||
where id > ?""", (self.mw.col.sched.dayCutoff-86400)*1000)
|
||||
cards = cards or 0
|
||||
thetime = thetime or 0
|
||||
buf = _("Studied %(a)d cards in %(b)s today.") % dict(
|
||||
a=cards, b=fmtTimeSpan(thetime))
|
||||
msgp1 = ngettext("Studied %d card", "Studied %d cards", cards) % cards
|
||||
buf = "%s in %s today." % (msgp1, fmtTimeSpan(thetime))
|
||||
return buf
|
||||
|
||||
def _renderDeckTree(self, nodes, depth=0):
|
||||
|
@ -288,7 +289,7 @@ where id > ?""", (self.mw.col.sched.dayCutoff-86400)*1000)
|
|||
"select count() from cards where did in {0} or "
|
||||
"odid in {0}".format(ids2str(dids)))
|
||||
if cnt:
|
||||
extra = _(" It has %d cards.") % cnt
|
||||
extra = ngettext(" It has %d card.", " It has %d cards.", cnt) % cnt
|
||||
else:
|
||||
extra = None
|
||||
if deck['dyn'] or not extra or askUser(
|
||||
|
|
|
@ -8,6 +8,7 @@ from anki.utils import ids2str
|
|||
from aqt.utils import showInfo, showWarning, openHelp, getOnlyText, askUser, \
|
||||
tooltip
|
||||
from operator import itemgetter
|
||||
from anki.lang import ngettext
|
||||
|
||||
class DeckConf(QDialog):
|
||||
def __init__(self, mw, deck):
|
||||
|
@ -92,7 +93,8 @@ class DeckConf(QDialog):
|
|||
continue
|
||||
if d['conf'] == conf['id']:
|
||||
cnt += 1
|
||||
self.form.count.setText(_("%d decks use this options group") % cnt)
|
||||
self.form.count.setText(ngettext("%d deck uses this options group", \
|
||||
"%d decks use this options group", cnt) % cnt)
|
||||
|
||||
def addGroup(self):
|
||||
name = getOnlyText(_("New options group name:"))
|
||||
|
@ -132,7 +134,9 @@ class DeckConf(QDialog):
|
|||
deck = self.mw.col.decks.get(did)
|
||||
deck['conf'] = self.deck['conf']
|
||||
self.mw.col.decks.save(deck)
|
||||
tooltip(_("%d decks updated.") % len(self.childDids))
|
||||
|
||||
tooltip(ngettext("%d deck updated.", "%d decks updated.", \
|
||||
len(self.childDids)) % len(self.childDids))
|
||||
|
||||
# Loading
|
||||
##################################################
|
||||
|
|
|
@ -6,6 +6,7 @@ from aqt.qt import *
|
|||
import anki, aqt, aqt.tagedit
|
||||
from aqt.utils import getSaveFile, tooltip, showWarning
|
||||
from anki.exporting import exporters
|
||||
from anki.lang import ngettext
|
||||
|
||||
class ExportDialog(QDialog):
|
||||
|
||||
|
@ -63,7 +64,8 @@ class ExportDialog(QDialog):
|
|||
else:
|
||||
os.unlink(file)
|
||||
self.exporter.exportInto(file)
|
||||
tooltip(_("%d exported.") % self.exporter.count)
|
||||
tooltip(ngettext("%d card exported.", "%d cards exported.", \
|
||||
self.exporter.count) % self.exporter.count)
|
||||
finally:
|
||||
self.mw.progress.finish()
|
||||
QDialog.accept(self)
|
||||
|
|
|
@ -19,6 +19,7 @@ from aqt.utils import saveGeom, restoreGeom, showInfo, showWarning, \
|
|||
saveState, restoreState, getOnlyText, askUser, GetTextDialog, \
|
||||
askUserDialog, applyStyles, getText, showText, showCritical, getFile, \
|
||||
tooltip, openHelp, openLink
|
||||
from anki.lang import ngettext
|
||||
|
||||
class AnkiQt(QMainWindow):
|
||||
def __init__(self, app, profileManager, args):
|
||||
|
@ -893,16 +894,16 @@ will be lost. Continue?"""))
|
|||
return
|
||||
report = self.col.emptyCardReport(cids)
|
||||
self.progress.finish()
|
||||
diag, box = showText(
|
||||
_("%(cnt)d cards to delete:\n\n%(rep)s") % dict(
|
||||
cnt=len(cids), rep=report), run=False)
|
||||
part1 = ngettext("%d card", "%d cards", len(cids))
|
||||
part2 = "to delete:\n\n%s" % report
|
||||
diag, box = showText("%s %s" % (part1, part2), run=False)
|
||||
box.addButton(_("Delete Cards"), QDialogButtonBox.AcceptRole)
|
||||
box.button(QDialogButtonBox.Close).setDefault(True)
|
||||
def onDelete():
|
||||
QDialog.accept(diag)
|
||||
self.checkpoint(_("Delete Empty"))
|
||||
self.col.remCards(cids)
|
||||
tooltip(_("%d cards deleted.") % len(cids))
|
||||
tooltip(ngettext("%d card deleted.", "%d cards deleted.", len(cids)) % len(cids))
|
||||
self.reset()
|
||||
diag.connect(box, SIGNAL("accepted()"), onDelete)
|
||||
diag.show()
|
||||
|
|
|
@ -7,6 +7,7 @@ from aqt.utils import showInfo, askUser, getText, maybeHideClose, openHelp
|
|||
import aqt.modelchooser, aqt.clayout
|
||||
from anki import stdmodels
|
||||
from aqt.utils import saveGeom, restoreGeom
|
||||
from anki.lang import ngettext
|
||||
|
||||
class Models(QDialog):
|
||||
def __init__(self, mw, parent=None):
|
||||
|
@ -62,8 +63,9 @@ class Models(QDialog):
|
|||
self.models.sort(key=itemgetter("name"))
|
||||
self.form.modelsList.clear()
|
||||
for m in self.models:
|
||||
item = QListWidgetItem(_("%(name)s [%(notes)d notes]") % dict(
|
||||
name=m['name'], notes=self.mm.useCount(m)))
|
||||
item = QListWidgetItem(ngettext("%s [%d note]", "%s [%d notes]", \
|
||||
self.mm.useCount(m)) % (
|
||||
m['name'], self.mm.useCount(m)))
|
||||
self.form.modelsList.addItem(item)
|
||||
self.form.modelsList.setCurrentRow(row)
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ from anki.sound import playFromText, clearAudioQueue, hasSound, play
|
|||
from aqt.utils import mungeQA, getBase, shortcut, openLink, tooltip
|
||||
from aqt.sound import getAudio
|
||||
import aqt
|
||||
from anki.lang import ngettext
|
||||
|
||||
class Reviewer(object):
|
||||
"Manage reviews. Maintains a separate state."
|
||||
|
@ -82,9 +83,9 @@ class Reviewer(object):
|
|||
self._showQuestion()
|
||||
elapsed = self.mw.col.timeboxReached()
|
||||
if elapsed:
|
||||
tooltip(_("%(cards)d cards studied in %(mins)s minutes.") %
|
||||
dict(cards=elapsed[1], mins=elapsed[0]/60),
|
||||
period=5000)
|
||||
part1 = ngettext("%d card studied in", "%d cards studied in", elapsed[1]) % elapsed[1]
|
||||
part2 = ngettext("%s minute.", "%s minutes.", elapsed[0]/60) % (elapsed[0]/60)
|
||||
tooltip("%s %s" % (part1, part2), period=5000)
|
||||
self.mw.col.startTimebox()
|
||||
|
||||
# Audio
|
||||
|
|
Loading…
Reference in a new issue