update TR references that crossed multiple lines
This commit is contained in:
parent
b7587cb8d2
commit
e687552aeb
@ -10,7 +10,6 @@ from anki.collection import Collection
|
||||
from anki.consts import *
|
||||
from anki.decks import DeckID, DeckManager
|
||||
from anki.importing.base import Importer
|
||||
from anki.lang import TR
|
||||
from anki.models import NoteTypeID
|
||||
from anki.notes import NoteID
|
||||
from anki.utils import intTime, joinFields, splitFields, stripHTMLMedia
|
||||
@ -142,22 +141,19 @@ class Anki2Importer(Importer):
|
||||
|
||||
if dupesIgnored:
|
||||
self.log.append(
|
||||
self.dst.tr(
|
||||
TR.IMPORTING_NOTES_THAT_COULD_NOT_BE_IMPORTED, val=len(dupesIgnored)
|
||||
self.dst.tr.importing_notes_that_could_not_be_imported(
|
||||
val=len(dupesIgnored)
|
||||
)
|
||||
)
|
||||
if update:
|
||||
self.log.append(
|
||||
self.dst.tr(
|
||||
TR.IMPORTING_NOTES_UPDATED_AS_FILE_HAD_NEWER, val=len(update)
|
||||
)
|
||||
self.dst.tr.importing_notes_updated_as_file_had_newer(val=len(update))
|
||||
)
|
||||
if add:
|
||||
self.log.append(self.dst.tr.importing_notes_added_from_file(val=len(add)))
|
||||
if dupesIdentical:
|
||||
self.log.append(
|
||||
self.dst.tr(
|
||||
TR.IMPORTING_NOTES_SKIPPED_AS_THEYRE_ALREADY_IN,
|
||||
self.dst.tr.importing_notes_skipped_as_theyre_already_in(
|
||||
val=len(dupesIdentical),
|
||||
)
|
||||
)
|
||||
|
@ -7,7 +7,6 @@ from typing import Any, List, Optional, TextIO, Union
|
||||
|
||||
from anki.collection import Collection
|
||||
from anki.importing.noteimp import ForeignNote, NoteImporter
|
||||
from anki.lang import TR
|
||||
|
||||
|
||||
class TextImporter(NoteImporter):
|
||||
@ -41,8 +40,7 @@ class TextImporter(NoteImporter):
|
||||
if len(row) != self.numFields:
|
||||
if row:
|
||||
log.append(
|
||||
self.col.tr(
|
||||
TR.IMPORTING_ROWS_HAD_NUM1D_FIELDS_EXPECTED_NUM2D,
|
||||
self.col.tr.importing_rows_had_num1d_fields_expected_num2d(
|
||||
row=" ".join(row),
|
||||
found=len(row),
|
||||
expected=self.numFields,
|
||||
|
@ -9,7 +9,6 @@ from anki.collection import Collection
|
||||
from anki.config import Config
|
||||
from anki.consts import NEW_CARDS_RANDOM, STARTING_FACTOR
|
||||
from anki.importing.base import Importer
|
||||
from anki.lang import TR
|
||||
from anki.models import NoteTypeID
|
||||
from anki.notes import NoteID
|
||||
from anki.utils import (
|
||||
@ -177,9 +176,7 @@ class NoteImporter(Importer):
|
||||
if data:
|
||||
updates.append(data)
|
||||
updateLog.append(
|
||||
self.col.tr(
|
||||
TR.IMPORTING_FIRST_FIELD_MATCHED, val=fld0
|
||||
)
|
||||
self.col.tr.importing_first_field_matched(val=fld0)
|
||||
)
|
||||
dupeCount += 1
|
||||
found = True
|
||||
@ -191,8 +188,7 @@ class NoteImporter(Importer):
|
||||
# only show message once, no matter how many
|
||||
# duplicates are in the collection already
|
||||
updateLog.append(
|
||||
self.col.tr(
|
||||
TR.IMPORTING_ADDED_DUPLICATE_WITH_FIRST_FIELD,
|
||||
self.col.tr.importing_added_duplicate_with_first_field(
|
||||
val=fld0,
|
||||
)
|
||||
)
|
||||
|
@ -10,7 +10,7 @@ from typing import Any, Dict, List, Optional, Sequence, Tuple, Union
|
||||
|
||||
import anki
|
||||
from anki.consts import *
|
||||
from anki.lang import TR, FormatTimeSpan
|
||||
from anki.lang import FormatTimeSpan
|
||||
from anki.utils import ids2str
|
||||
|
||||
# Card stats
|
||||
@ -421,9 +421,8 @@ group by day order by day"""
|
||||
self._line(
|
||||
i,
|
||||
"Average answer time",
|
||||
self.col.tr(
|
||||
TR.STATISTICS_AVERAGE_ANSWER_TIME,
|
||||
**{"cards-per-minute": perMin, "average-seconds": average_secs},
|
||||
self.col.tr.statistics_average_answer_time(
|
||||
average_seconds=average_secs
|
||||
),
|
||||
)
|
||||
return self._lineTbl(i), int(tot)
|
||||
|
@ -9,7 +9,7 @@ from re import Match
|
||||
|
||||
import stringcase
|
||||
|
||||
TR_REF = re.compile(r"tr\(TR.([^,) ]+),\s*([^)]+)\)")
|
||||
TR_REF = re.compile(r"tr\(\s*TR.([^,) ]+),\s*([^)]+)\)")
|
||||
|
||||
|
||||
def repl(m: Match) -> str:
|
||||
@ -19,19 +19,10 @@ def repl(m: Match) -> str:
|
||||
|
||||
|
||||
def update_py(path: str) -> None:
|
||||
buf = []
|
||||
changed = False
|
||||
for line in open(path):
|
||||
line2 = TR_REF.sub(repl, line)
|
||||
if line != line2:
|
||||
print(line2)
|
||||
buf.append(line2)
|
||||
changed = True
|
||||
else:
|
||||
buf.append(line)
|
||||
|
||||
if changed:
|
||||
open(path, "w").writelines(buf)
|
||||
buf = open(path).read()
|
||||
buf2 = TR_REF.sub(repl, buf)
|
||||
if buf != buf2:
|
||||
open(path, "w").writelines(buf2)
|
||||
print("updated", path)
|
||||
|
||||
|
||||
|
@ -380,8 +380,7 @@ def setupGL(pm: aqt.profiles.ProfileManager) -> None:
|
||||
QMessageBox.critical(
|
||||
None,
|
||||
tr.qt_misc_error(),
|
||||
tr(
|
||||
TR.QT_MISC_ERROR_LOADING_GRAPHICS_DRIVER,
|
||||
tr.qt_misc_error_loading_graphics_driver(
|
||||
mode=driver.value,
|
||||
context=context,
|
||||
),
|
||||
|
@ -8,7 +8,7 @@ from anki.lang import without_unicode_isolation
|
||||
from anki.utils import versionWithBuild
|
||||
from aqt.addons import AddonManager, AddonMeta
|
||||
from aqt.qt import *
|
||||
from aqt.utils import TR, disable_help_button, supportText, tooltip, tr
|
||||
from aqt.utils import disable_help_button, supportText, tooltip, tr
|
||||
|
||||
|
||||
class ClosableQDialog(QDialog):
|
||||
@ -209,8 +209,8 @@ def show(mw: aqt.AnkiQt) -> QDialog:
|
||||
)
|
||||
)
|
||||
|
||||
abouttext += "<p>" + tr(
|
||||
TR.ABOUT_WRITTEN_BY_DAMIEN_ELMES_WITH_PATCHES, cont=", ".join(allusers)
|
||||
abouttext += "<p>" + tr.about_written_by_damien_elmes_with_patches(
|
||||
cont=", ".join(allusers)
|
||||
)
|
||||
abouttext += f"<p>{tr.about_if_you_have_contributed_and_are()}"
|
||||
abouttext += f"<p>{tr.about_a_big_thanks_to_all_the()}"
|
||||
|
@ -28,7 +28,6 @@ from anki.lang import without_unicode_isolation
|
||||
from aqt import gui_hooks
|
||||
from aqt.qt import *
|
||||
from aqt.utils import (
|
||||
TR,
|
||||
askUser,
|
||||
disable_help_button,
|
||||
getFile,
|
||||
@ -220,8 +219,7 @@ class AddonManager:
|
||||
pass
|
||||
except:
|
||||
showWarning(
|
||||
tr(
|
||||
TR.ADDONS_FAILED_TO_LOAD,
|
||||
tr.addons_failed_to_load(
|
||||
name=addon.human_name(),
|
||||
traceback=traceback.format_exc(),
|
||||
)
|
||||
@ -286,8 +284,7 @@ class AddonManager:
|
||||
if conflicting:
|
||||
addons = ", ".join(self.addonName(f) for f in conflicting)
|
||||
showInfo(
|
||||
tr(
|
||||
TR.ADDONS_THE_FOLLOWING_ADDONS_ARE_INCOMPATIBLE_WITH,
|
||||
tr.addons_the_following_addons_are_incompatible_with(
|
||||
name=addon.human_name(),
|
||||
found=addons,
|
||||
),
|
||||
@ -1090,8 +1087,7 @@ class DownloaderInstaller(QObject):
|
||||
def _progress_callback(self, up: int, down: int) -> None:
|
||||
self.dl_bytes += down
|
||||
self.mgr.mw.progress.update(
|
||||
label=tr(
|
||||
TR.ADDONS_DOWNLOADING_ADBD_KB02FKB,
|
||||
label=tr.addons_downloading_adbd_kb02fkb(
|
||||
part=len(self.log) + 1,
|
||||
total=len(self.ids),
|
||||
kilobytes=self.dl_bytes / 1024,
|
||||
@ -1459,8 +1455,7 @@ class ConfigEditor(QDialog):
|
||||
restoreSplitter(self.form.splitter, "addonconf")
|
||||
self.setWindowTitle(
|
||||
without_unicode_isolation(
|
||||
tr(
|
||||
TR.ADDONS_CONFIG_WINDOW_TITLE,
|
||||
tr.addons_config_window_title(
|
||||
name=self.mgr.addon_meta(addon).human_name(),
|
||||
)
|
||||
)
|
||||
@ -1528,8 +1523,7 @@ class ConfigEditor(QDialog):
|
||||
erroneous_conf=erroneous_conf,
|
||||
)
|
||||
else:
|
||||
msg = tr(
|
||||
TR.ADDONS_CONFIG_VALIDATION_ERROR,
|
||||
msg = tr.addons_config_validation_error(
|
||||
problem=e.message,
|
||||
path=path,
|
||||
schema=str(schema),
|
||||
|
@ -53,7 +53,6 @@ from aqt.sidebar import SidebarTreeView
|
||||
from aqt.tag_ops import add_tags, clear_unused_tags, remove_tags_for_notes
|
||||
from aqt.theme import theme_manager
|
||||
from aqt.utils import (
|
||||
TR,
|
||||
HelpPage,
|
||||
KeyboardModifiersPressed,
|
||||
askUser,
|
||||
@ -801,8 +800,7 @@ QTableView {{ gridline-color: {grid} }}
|
||||
None,
|
||||
"preview",
|
||||
lambda _editor: self.onTogglePreview(),
|
||||
tr(
|
||||
TR.BROWSING_PREVIEW_SELECTED_CARD,
|
||||
tr.browsing_preview_selected_card(
|
||||
val=shortcut(preview_shortcut),
|
||||
),
|
||||
tr.actions_preview(),
|
||||
|
@ -17,7 +17,6 @@ from aqt.schema_change_tracker import ChangeTracker
|
||||
from aqt.sound import av_player, play_clicked_audio
|
||||
from aqt.theme import theme_manager
|
||||
from aqt.utils import (
|
||||
TR,
|
||||
HelpPage,
|
||||
askUser,
|
||||
disable_help_button,
|
||||
@ -559,8 +558,7 @@ class CardLayout(QDialog):
|
||||
|
||||
template = self.current_template()
|
||||
cards = tr.card_templates_card_count(count=card_cnt)
|
||||
msg = tr(
|
||||
TR.CARD_TEMPLATES_DELETE_THE_AS_CARD_TYPE_AND,
|
||||
msg = tr.card_templates_delete_the_as_card_type_and(
|
||||
template=template["name"],
|
||||
cards=cards,
|
||||
)
|
||||
|
@ -5,7 +5,7 @@ import aqt
|
||||
from anki.collection import SearchNode
|
||||
from anki.consts import *
|
||||
from aqt.qt import *
|
||||
from aqt.utils import TR, disable_help_button, showInfo, showWarning, tr
|
||||
from aqt.utils import disable_help_button, showInfo, showWarning, tr
|
||||
|
||||
RADIO_NEW = 1
|
||||
RADIO_REV = 2
|
||||
@ -68,9 +68,7 @@ class CustomStudy(QDialog):
|
||||
new, self.conf["new"]["perDay"] - self.deck["newToday"][1]
|
||||
)
|
||||
newExceeding = min(new, new - newUnderLearning)
|
||||
tit = tr(
|
||||
TR.CUSTOM_STUDY_NEW_CARDS_IN_DECK_OVER_TODAY, val=plus(newExceeding)
|
||||
)
|
||||
tit = tr.custom_study_new_cards_in_deck_over_today(val=plus(newExceeding))
|
||||
pre = tr.custom_study_increase_todays_new_card_limit_by()
|
||||
sval = min(new, self.deck.get("extendNew", 10))
|
||||
smin = -DYN_MAX_SIZE
|
||||
@ -82,9 +80,7 @@ class CustomStudy(QDialog):
|
||||
rev, self.conf["rev"]["perDay"] - self.deck["revToday"][1]
|
||||
)
|
||||
revExceeding = min(rev, rev - revUnderLearning)
|
||||
tit = tr(
|
||||
TR.CUSTOM_STUDY_REVIEWS_DUE_IN_DECK_OVER_TODAY, val=plus(revExceeding)
|
||||
)
|
||||
tit = tr.custom_study_reviews_due_in_deck_over_today(val=plus(revExceeding))
|
||||
pre = tr.custom_study_increase_todays_review_limit_by()
|
||||
sval = min(rev, self.deck.get("extendRev", 10))
|
||||
smin = -DYN_MAX_SIZE
|
||||
|
@ -35,7 +35,6 @@ from aqt.qt import *
|
||||
from aqt.sound import av_player
|
||||
from aqt.theme import theme_manager
|
||||
from aqt.utils import (
|
||||
TR,
|
||||
HelpPage,
|
||||
KeyboardModifiersPressed,
|
||||
disable_help_button,
|
||||
@ -957,8 +956,7 @@ class Editor:
|
||||
client.timeout = 30
|
||||
with client.get(url) as response:
|
||||
if response.status_code != 200:
|
||||
error_msg = tr(
|
||||
TR.QT_MISC_UNEXPECTED_RESPONSE_CODE,
|
||||
error_msg = tr.qt_misc_unexpected_response_code(
|
||||
val=response.status_code,
|
||||
)
|
||||
return None
|
||||
|
@ -24,7 +24,7 @@ from anki.sync import SyncAuth
|
||||
from anki.utils import intTime, isMac, isWin
|
||||
from aqt import appHelpSite
|
||||
from aqt.qt import *
|
||||
from aqt.utils import TR, disable_help_button, showWarning, tr
|
||||
from aqt.utils import disable_help_button, showWarning, tr
|
||||
|
||||
# Profile handling
|
||||
##########################################################################
|
||||
@ -516,8 +516,7 @@ create table if not exists profiles
|
||||
with open(p, "w", encoding="utf8") as file:
|
||||
file.write(
|
||||
without_unicode_isolation(
|
||||
tr(
|
||||
TR.PROFILES_FOLDER_README,
|
||||
tr.profiles_folder_readme(
|
||||
link=f"{appHelpSite}files?id=startup-options",
|
||||
)
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user