Merge branch 'master' of github.com:dae/ankiqt

Conflicts:
	aqt/browser.py
This commit is contained in:
Damien Elmes 2012-09-10 09:21:23 +09:00
commit 38b92fedf5
7 changed files with 32 additions and 18 deletions

View file

@ -17,6 +17,7 @@ from anki.hooks import runHook, addHook, remHook
from aqt.webview import AnkiWebView from aqt.webview import AnkiWebView
from aqt.toolbar import Toolbar from aqt.toolbar import Toolbar
from anki.consts import * from anki.consts import *
from anki.lang import ngettext
COLOUR_SUSPENDED = "#FFFFB2" COLOUR_SUSPENDED = "#FFFFB2"
COLOUR_MARKED = "#D9B2E9" COLOUR_MARKED = "#D9B2E9"
@ -1179,13 +1180,15 @@ update cards set usn=?, mod=?, did=? where odid=0 and id in """ + ids2str(
self.mw.progress.start() self.mw.progress.start()
res = self.mw.col.findDupes(fname, search) res = self.mw.col.findDupes(fname, search)
t = "<html><body>" t = "<html><body>"
t += _("Found %(a)d group of duplicates across %(b)d notes.") % dict( part1 = ngettext("Found %d duplicate in", "Found %d duplicates in", \
b=sum(len(r[1]) for r in res), a=len(res)) 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>" t += "<p><ol>"
for val, nids in res: for val, nids in res:
t += '<li><a href="%s">%s</a>: %s</a>' % ( t += '<li><a href="%s">%s</a>: %s</a>' % (
"nid:" + ",".join(str(id) for id in nids), "nid:" + ",".join(str(id) for id in nids),
_("%d notes") % len(nids), ngettext("%d note", "%d notes", len(nids)) % len(nids),
cgi.escape(val)) cgi.escape(val))
t += "</ol>" t += "</ol>"
t += "</body></html>" t += "</body></html>"

View file

@ -10,6 +10,7 @@ import anki.js
from anki.errors import DeckRenameError from anki.errors import DeckRenameError
import aqt import aqt
from anki.sound import clearAudioQueue from anki.sound import clearAudioQueue
from anki.lang import ngettext
class DeckBrowser(object): class DeckBrowser(object):
@ -155,8 +156,8 @@ select count(), sum(time)/1000 from revlog
where id > ?""", (self.mw.col.sched.dayCutoff-86400)*1000) where id > ?""", (self.mw.col.sched.dayCutoff-86400)*1000)
cards = cards or 0 cards = cards or 0
thetime = thetime or 0 thetime = thetime or 0
buf = _("Studied %(a)d cards in %(b)s today.") % dict( msgp1 = ngettext("Studied %d card", "Studied %d cards", cards) % cards
a=cards, b=fmtTimeSpan(thetime)) buf = "%s in %s today." % (msgp1, fmtTimeSpan(thetime))
return buf return buf
def _renderDeckTree(self, nodes, depth=0): 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 " "select count() from cards where did in {0} or "
"odid in {0}".format(ids2str(dids))) "odid in {0}".format(ids2str(dids)))
if cnt: if cnt:
extra = _(" It has %d cards.") % cnt extra = ngettext(" It has %d card.", " It has %d cards.", cnt) % cnt
else: else:
extra = None extra = None
if deck['dyn'] or not extra or askUser( if deck['dyn'] or not extra or askUser(

View file

@ -8,6 +8,7 @@ from anki.utils import ids2str
from aqt.utils import showInfo, showWarning, openHelp, getOnlyText, askUser, \ from aqt.utils import showInfo, showWarning, openHelp, getOnlyText, askUser, \
tooltip tooltip
from operator import itemgetter from operator import itemgetter
from anki.lang import ngettext
class DeckConf(QDialog): class DeckConf(QDialog):
def __init__(self, mw, deck): def __init__(self, mw, deck):
@ -92,7 +93,8 @@ class DeckConf(QDialog):
continue continue
if d['conf'] == conf['id']: if d['conf'] == conf['id']:
cnt += 1 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): def addGroup(self):
name = getOnlyText(_("New options group name:")) name = getOnlyText(_("New options group name:"))
@ -132,7 +134,9 @@ class DeckConf(QDialog):
deck = self.mw.col.decks.get(did) deck = self.mw.col.decks.get(did)
deck['conf'] = self.deck['conf'] deck['conf'] = self.deck['conf']
self.mw.col.decks.save(deck) 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 # Loading
################################################## ##################################################

View file

@ -6,6 +6,7 @@ from aqt.qt import *
import anki, aqt, aqt.tagedit import anki, aqt, aqt.tagedit
from aqt.utils import getSaveFile, tooltip, showWarning from aqt.utils import getSaveFile, tooltip, showWarning
from anki.exporting import exporters from anki.exporting import exporters
from anki.lang import ngettext
class ExportDialog(QDialog): class ExportDialog(QDialog):
@ -63,7 +64,8 @@ class ExportDialog(QDialog):
else: else:
os.unlink(file) os.unlink(file)
self.exporter.exportInto(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: finally:
self.mw.progress.finish() self.mw.progress.finish()
QDialog.accept(self) QDialog.accept(self)

View file

@ -19,6 +19,7 @@ from aqt.utils import saveGeom, restoreGeom, showInfo, showWarning, \
saveState, restoreState, getOnlyText, askUser, GetTextDialog, \ saveState, restoreState, getOnlyText, askUser, GetTextDialog, \
askUserDialog, applyStyles, getText, showText, showCritical, getFile, \ askUserDialog, applyStyles, getText, showText, showCritical, getFile, \
tooltip, openHelp, openLink tooltip, openHelp, openLink
from anki.lang import ngettext
class AnkiQt(QMainWindow): class AnkiQt(QMainWindow):
def __init__(self, app, profileManager, args): def __init__(self, app, profileManager, args):
@ -893,16 +894,16 @@ will be lost. Continue?"""))
return return
report = self.col.emptyCardReport(cids) report = self.col.emptyCardReport(cids)
self.progress.finish() self.progress.finish()
diag, box = showText( part1 = ngettext("%d card", "%d cards", len(cids))
_("%(cnt)d cards to delete:\n\n%(rep)s") % dict( part2 = "to delete:\n\n%s" % report
cnt=len(cids), rep=report), run=False) diag, box = showText("%s %s" % (part1, part2), run=False)
box.addButton(_("Delete Cards"), QDialogButtonBox.AcceptRole) box.addButton(_("Delete Cards"), QDialogButtonBox.AcceptRole)
box.button(QDialogButtonBox.Close).setDefault(True) box.button(QDialogButtonBox.Close).setDefault(True)
def onDelete(): def onDelete():
QDialog.accept(diag) QDialog.accept(diag)
self.checkpoint(_("Delete Empty")) self.checkpoint(_("Delete Empty"))
self.col.remCards(cids) self.col.remCards(cids)
tooltip(_("%d cards deleted.") % len(cids)) tooltip(ngettext("%d card deleted.", "%d cards deleted.", len(cids)) % len(cids))
self.reset() self.reset()
diag.connect(box, SIGNAL("accepted()"), onDelete) diag.connect(box, SIGNAL("accepted()"), onDelete)
diag.show() diag.show()

View file

@ -7,6 +7,7 @@ from aqt.utils import showInfo, askUser, getText, maybeHideClose, openHelp
import aqt.modelchooser, aqt.clayout import aqt.modelchooser, aqt.clayout
from anki import stdmodels from anki import stdmodels
from aqt.utils import saveGeom, restoreGeom from aqt.utils import saveGeom, restoreGeom
from anki.lang import ngettext
class Models(QDialog): class Models(QDialog):
def __init__(self, mw, parent=None): def __init__(self, mw, parent=None):
@ -62,8 +63,9 @@ class Models(QDialog):
self.models.sort(key=itemgetter("name")) self.models.sort(key=itemgetter("name"))
self.form.modelsList.clear() self.form.modelsList.clear()
for m in self.models: for m in self.models:
item = QListWidgetItem(_("%(name)s [%(notes)d notes]") % dict( item = QListWidgetItem(ngettext("%s [%d note]", "%s [%d notes]", \
name=m['name'], notes=self.mm.useCount(m))) self.mm.useCount(m)) % (
m['name'], self.mm.useCount(m)))
self.form.modelsList.addItem(item) self.form.modelsList.addItem(item)
self.form.modelsList.setCurrentRow(row) self.form.modelsList.setCurrentRow(row)

View file

@ -12,6 +12,7 @@ from anki.sound import playFromText, clearAudioQueue, hasSound, play
from aqt.utils import mungeQA, getBase, shortcut, openLink, tooltip from aqt.utils import mungeQA, getBase, shortcut, openLink, tooltip
from aqt.sound import getAudio from aqt.sound import getAudio
import aqt import aqt
from anki.lang import ngettext
class Reviewer(object): class Reviewer(object):
"Manage reviews. Maintains a separate state." "Manage reviews. Maintains a separate state."
@ -82,9 +83,9 @@ class Reviewer(object):
self._showQuestion() self._showQuestion()
elapsed = self.mw.col.timeboxReached() elapsed = self.mw.col.timeboxReached()
if elapsed: if elapsed:
tooltip(_("%(cards)d cards studied in %(mins)s minutes.") % part1 = ngettext("%d card studied in", "%d cards studied in", elapsed[1]) % elapsed[1]
dict(cards=elapsed[1], mins=elapsed[0]/60), part2 = ngettext("%s minute.", "%s minutes.", elapsed[0]/60) % (elapsed[0]/60)
period=5000) tooltip("%s %s" % (part1, part2), period=5000)
self.mw.col.startTimebox() self.mw.col.startTimebox()
# Audio # Audio