mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
update some qt ngettext references
This commit is contained in:
parent
177d98489a
commit
1255e7530c
8 changed files with 18 additions and 22 deletions
|
@ -1574,9 +1574,7 @@ where id in %s"""
|
|||
self.model.focusedCard = self.model.cards[newRow]
|
||||
self.model.endReset()
|
||||
self.mw.reset()
|
||||
tooltip(
|
||||
ngettext("%d note deleted.", "%d notes deleted.", len(nids)) % len(nids)
|
||||
)
|
||||
tooltip(tr(TR.BROWSING_NOTE_DELETED, count=len(nids)))
|
||||
|
||||
# Deck change
|
||||
######################################################################
|
||||
|
@ -2001,8 +1999,8 @@ where id in %s"""
|
|||
t = ""
|
||||
groups = len(res)
|
||||
notes = sum(len(r[1]) for r in res)
|
||||
part1 = ngettext("%d group", "%d groups", groups) % groups
|
||||
part2 = ngettext("%d note", "%d notes", notes) % notes
|
||||
part1 = tr(TR.BROWSING_GROUP, count=groups)
|
||||
part2 = tr(TR.BROWSING_NOTE_COUNT, count=notes)
|
||||
t += tr(TR.BROWSING_FOUND_AS_ACROSS_BS) % dict(a=part1, b=part2)
|
||||
t += "<p><ol>"
|
||||
for val, nids in res:
|
||||
|
@ -2010,7 +2008,7 @@ where id in %s"""
|
|||
"""<li><a href=# onclick="pycmd('%s');return false;">%s</a>: %s</a>"""
|
||||
% (
|
||||
"nid:" + ",".join(str(id) for id in nids),
|
||||
ngettext("%d note", "%d notes", len(nids)) % len(nids),
|
||||
tr(TR.BROWSING_NOTE_COUNT, count=len(nids)),
|
||||
html.escape(val),
|
||||
)
|
||||
)
|
||||
|
|
|
@ -561,7 +561,7 @@ class CardLayout(QDialog):
|
|||
card_cnt = fut.result()
|
||||
|
||||
template = self.current_template()
|
||||
cards = ngettext("%d card", "%d cards", card_cnt) % card_cnt
|
||||
cards = tr(TR.CARD_TEMPLATES_CARD_COUNT, count=card_cnt)
|
||||
msg = tr(TR.CARD_TEMPLATES_DELETE_THE_AS_CARD_TYPE_AND) % dict(
|
||||
a=template["name"], b=cards
|
||||
)
|
||||
|
|
|
@ -285,7 +285,7 @@ class DeckBrowser:
|
|||
"odid in {0}".format(ids2str(dids))
|
||||
)
|
||||
if cnt:
|
||||
extra = ngettext(" It has %d card.", " It has %d cards.", cnt) % cnt
|
||||
extra = tr(TR.DECKS_IT_HAS_CARD, count=cnt)
|
||||
else:
|
||||
extra = None
|
||||
if (
|
||||
|
|
|
@ -122,7 +122,7 @@ class FieldDialog(QDialog):
|
|||
if len(self.model["flds"]) < 2:
|
||||
return showWarning(tr(TR.FIELDS_NOTES_REQUIRE_AT_LEAST_ONE_FIELD))
|
||||
count = self.mm.useCount(self.model)
|
||||
c = ngettext("%d note", "%d notes", count) % count
|
||||
c = tr(TR.BROWSING_NOTE_COUNT, count=count)
|
||||
if not askUser(tr(TR.FIELDS_DELETE_FIELD_FROM, val=c)):
|
||||
return
|
||||
if not self.change_tracker.mark_schema():
|
||||
|
|
|
@ -1217,7 +1217,7 @@ title="%s" %s>%s</button>""" % (
|
|||
if devMode:
|
||||
print("clock is off; ignoring")
|
||||
return
|
||||
diffText = ngettext("%s second", "%s seconds", diff) % diff
|
||||
diffText = tr(TR.QT_MISC_SECOND, count=diff)
|
||||
warn = (
|
||||
_(
|
||||
"""\
|
||||
|
|
|
@ -110,7 +110,7 @@ class Models(QDialog):
|
|||
|
||||
self.models = notetypes
|
||||
for m in self.models:
|
||||
mUse = ngettext("%d note", "%d notes", m.use_count) % m.use_count
|
||||
mUse = tr(TR.BROWSING_NOTE_COUNT, count=m.use_count)
|
||||
item = QListWidgetItem("%s [%s]" % (m.name, mUse))
|
||||
self.form.modelsList.addItem(item)
|
||||
self.form.modelsList.setCurrentRow(row)
|
||||
|
|
|
@ -92,12 +92,9 @@ class Reviewer:
|
|||
elapsed = self.mw.col.timeboxReached()
|
||||
if elapsed:
|
||||
assert not isinstance(elapsed, bool)
|
||||
part1 = (
|
||||
ngettext("%d card studied in", "%d cards studied in", elapsed[1])
|
||||
% elapsed[1]
|
||||
)
|
||||
part1 = tr(TR.STUDYING_CARD_STUDIED_IN, count=elapsed[1])
|
||||
mins = int(round(elapsed[0] / 60))
|
||||
part2 = ngettext("%s minute.", "%s minutes.", mins) % mins
|
||||
part2 = tr(TR.STUDYING_MINUTE, count=mins)
|
||||
fin = tr(TR.STUDYING_FINISH)
|
||||
diag = askUserDialog(
|
||||
"%s %s" % (part1, part2), [tr(TR.STUDYING_CONTINUE), fin]
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
import glob, re, json, stringcase
|
||||
|
||||
files = (
|
||||
glob.glob("../../pylib/**/*.py", recursive=True)
|
||||
# + glob.glob("../../qt/**/*.py", recursive=True)
|
||||
# glob.glob("../../pylib/**/*.py", recursive=True)
|
||||
glob.glob("../../qt/**/*.py", recursive=True)
|
||||
# glob.glob("../../qt/**/forms/*.ui", recursive=True)
|
||||
)
|
||||
string_re = re.compile(r'ngettext\(\s*"(.+?)",\s+".+?",\s+(.+?)\) % \2')
|
||||
string_re = re.compile(r'ngettext\(\s*"(.+?)",\s+".+?",\s+(.+?)\) % \2', re.DOTALL)
|
||||
|
||||
map = json.load(open("keys_by_text.json"))
|
||||
|
||||
|
@ -20,6 +20,8 @@ blacklist = {
|
|||
"~",
|
||||
"about:blank",
|
||||
"%d card imported.",
|
||||
# need to update manually
|
||||
"Browse (%(cur)d card shown; %(sel)s)",
|
||||
# previewer.py needs updating to fix these
|
||||
"Shortcut key: R",
|
||||
"Shortcut key: B",
|
||||
|
@ -72,7 +74,7 @@ def repl(m):
|
|||
|
||||
screaming = stringcase.constcase(key)
|
||||
|
||||
ret = f"tr_legacyglobal(TR.{screaming}, count={m.group(2)})"
|
||||
ret = f"tr(TR.{screaming}, count={m.group(2)})"
|
||||
print(ret)
|
||||
return ret
|
||||
|
||||
|
@ -84,7 +86,6 @@ for file in files:
|
|||
buf2 = string_re.sub(repl, buf)
|
||||
if buf != buf2:
|
||||
lines = buf2.split("\n")
|
||||
lines.insert(3, "from anki.rsbackend import TR")
|
||||
lines.insert(3, "from anki.lang import tr_legacyglobal")
|
||||
lines.insert(3, "from aqt.utils import tr, TR")
|
||||
buf2 = "\n".join(lines)
|
||||
open(file, "w").write(buf2)
|
||||
|
|
Loading…
Reference in a new issue