mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 22:42:25 -04:00
update remaining TR references in .py files
This commit is contained in:
parent
3199fa80d5
commit
785db39a56
2 changed files with 34 additions and 45 deletions
|
@ -20,14 +20,7 @@ from aqt.models import Models
|
||||||
from aqt.qt import *
|
from aqt.qt import *
|
||||||
from aqt.tag_ops import remove_tags_for_all_notes, rename_tag, reparent_tags
|
from aqt.tag_ops import remove_tags_for_all_notes, rename_tag, reparent_tags
|
||||||
from aqt.theme import ColoredIcon, theme_manager
|
from aqt.theme import ColoredIcon, theme_manager
|
||||||
from aqt.utils import (
|
from aqt.utils import KeyboardModifiersPressed, askUser, getOnlyText, showWarning, tr
|
||||||
TR,
|
|
||||||
KeyboardModifiersPressed,
|
|
||||||
askUser,
|
|
||||||
getOnlyText,
|
|
||||||
showWarning,
|
|
||||||
tr,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class SidebarTool(Enum):
|
class SidebarTool(Enum):
|
||||||
|
@ -124,14 +117,12 @@ class SidebarItem:
|
||||||
|
|
||||||
def add_simple(
|
def add_simple(
|
||||||
self,
|
self,
|
||||||
name: Union[str, TR],
|
name: str,
|
||||||
icon: Union[str, ColoredIcon],
|
icon: Union[str, ColoredIcon],
|
||||||
type: SidebarItemType,
|
type: SidebarItemType,
|
||||||
search_node: Optional[SearchNode],
|
search_node: Optional[SearchNode],
|
||||||
) -> SidebarItem:
|
) -> SidebarItem:
|
||||||
"Add child sidebar item, and return it."
|
"Add child sidebar item, and return it."
|
||||||
if not isinstance(name, str):
|
|
||||||
name = tr(name)
|
|
||||||
item = SidebarItem(
|
item = SidebarItem(
|
||||||
name=name,
|
name=name,
|
||||||
icon=icon,
|
icon=icon,
|
||||||
|
@ -271,9 +262,9 @@ class SidebarModel(QAbstractItemModel):
|
||||||
|
|
||||||
|
|
||||||
class SidebarToolbar(QToolBar):
|
class SidebarToolbar(QToolBar):
|
||||||
_tools: Tuple[Tuple[SidebarTool, str, TR], ...] = (
|
_tools: Tuple[Tuple[SidebarTool, str, Callable[[], str]], ...] = (
|
||||||
(SidebarTool.SEARCH, ":/icons/magnifying_glass.svg", TR.ACTIONS_SEARCH),
|
(SidebarTool.SEARCH, ":/icons/magnifying_glass.svg", tr.actions_search),
|
||||||
(SidebarTool.SELECT, ":/icons/select.svg", TR.ACTIONS_SELECT),
|
(SidebarTool.SELECT, ":/icons/select.svg", tr.actions_select),
|
||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, sidebar: SidebarTreeView) -> None:
|
def __init__(self, sidebar: SidebarTreeView) -> None:
|
||||||
|
@ -288,7 +279,7 @@ class SidebarToolbar(QToolBar):
|
||||||
def _setup_tools(self) -> None:
|
def _setup_tools(self) -> None:
|
||||||
for row, tool in enumerate(self._tools):
|
for row, tool in enumerate(self._tools):
|
||||||
action = self.addAction(
|
action = self.addAction(
|
||||||
theme_manager.icon_from_resources(tool[1]), tr(tool[2])
|
theme_manager.icon_from_resources(tool[1]), tool[2]()
|
||||||
)
|
)
|
||||||
action.setCheckable(True)
|
action.setCheckable(True)
|
||||||
action.setShortcut(f"Alt+{row + 1}")
|
action.setShortcut(f"Alt+{row + 1}")
|
||||||
|
@ -726,7 +717,7 @@ class SidebarTreeView(QTreeView):
|
||||||
self,
|
self,
|
||||||
*,
|
*,
|
||||||
root: SidebarItem,
|
root: SidebarItem,
|
||||||
name: TR,
|
name: str,
|
||||||
icon: Union[str, ColoredIcon],
|
icon: Union[str, ColoredIcon],
|
||||||
collapse_key: Config.Bool.Key.V,
|
collapse_key: Config.Bool.Key.V,
|
||||||
type: Optional[SidebarItemType] = None,
|
type: Optional[SidebarItemType] = None,
|
||||||
|
@ -735,7 +726,7 @@ class SidebarTreeView(QTreeView):
|
||||||
self.col.set_config_bool(collapse_key, not expanded)
|
self.col.set_config_bool(collapse_key, not expanded)
|
||||||
|
|
||||||
top = SidebarItem(
|
top = SidebarItem(
|
||||||
tr(name),
|
name,
|
||||||
icon,
|
icon,
|
||||||
on_expanded=update,
|
on_expanded=update,
|
||||||
expanded=not self.col.get_config_bool(collapse_key),
|
expanded=not self.col.get_config_bool(collapse_key),
|
||||||
|
@ -754,7 +745,7 @@ class SidebarTreeView(QTreeView):
|
||||||
|
|
||||||
root = self._section_root(
|
root = self._section_root(
|
||||||
root=root,
|
root=root,
|
||||||
name=TR.BROWSING_SIDEBAR_SAVED_SEARCHES,
|
name=tr.browsing_sidebar_saved_searches(),
|
||||||
icon=icon,
|
icon=icon,
|
||||||
collapse_key=Config.Bool.COLLAPSE_SAVED_SEARCHES,
|
collapse_key=Config.Bool.COLLAPSE_SAVED_SEARCHES,
|
||||||
type=SidebarItemType.SAVED_SEARCH_ROOT,
|
type=SidebarItemType.SAVED_SEARCH_ROOT,
|
||||||
|
@ -776,7 +767,7 @@ class SidebarTreeView(QTreeView):
|
||||||
icon = ":/icons/clock.svg"
|
icon = ":/icons/clock.svg"
|
||||||
root = self._section_root(
|
root = self._section_root(
|
||||||
root=root,
|
root=root,
|
||||||
name=TR.BROWSING_TODAY,
|
name=tr.browsing_today(),
|
||||||
icon=icon,
|
icon=icon,
|
||||||
collapse_key=Config.Bool.COLLAPSE_TODAY,
|
collapse_key=Config.Bool.COLLAPSE_TODAY,
|
||||||
type=SidebarItemType.TODAY_ROOT,
|
type=SidebarItemType.TODAY_ROOT,
|
||||||
|
@ -784,31 +775,31 @@ class SidebarTreeView(QTreeView):
|
||||||
type = SidebarItemType.TODAY
|
type = SidebarItemType.TODAY
|
||||||
|
|
||||||
root.add_simple(
|
root.add_simple(
|
||||||
name=TR.BROWSING_SIDEBAR_DUE_TODAY,
|
name=tr.browsing_sidebar_due_today(),
|
||||||
icon=icon,
|
icon=icon,
|
||||||
type=type,
|
type=type,
|
||||||
search_node=SearchNode(due_on_day=0),
|
search_node=SearchNode(due_on_day=0),
|
||||||
)
|
)
|
||||||
root.add_simple(
|
root.add_simple(
|
||||||
name=TR.BROWSING_ADDED_TODAY,
|
name=tr.browsing_added_today(),
|
||||||
icon=icon,
|
icon=icon,
|
||||||
type=type,
|
type=type,
|
||||||
search_node=SearchNode(added_in_days=1),
|
search_node=SearchNode(added_in_days=1),
|
||||||
)
|
)
|
||||||
root.add_simple(
|
root.add_simple(
|
||||||
name=TR.BROWSING_EDITED_TODAY,
|
name=tr.browsing_edited_today(),
|
||||||
icon=icon,
|
icon=icon,
|
||||||
type=type,
|
type=type,
|
||||||
search_node=SearchNode(edited_in_days=1),
|
search_node=SearchNode(edited_in_days=1),
|
||||||
)
|
)
|
||||||
root.add_simple(
|
root.add_simple(
|
||||||
name=TR.BROWSING_STUDIED_TODAY,
|
name=tr.browsing_studied_today(),
|
||||||
icon=icon,
|
icon=icon,
|
||||||
type=type,
|
type=type,
|
||||||
search_node=SearchNode(rated=SearchNode.Rated(days=1)),
|
search_node=SearchNode(rated=SearchNode.Rated(days=1)),
|
||||||
)
|
)
|
||||||
root.add_simple(
|
root.add_simple(
|
||||||
name=TR.BROWSING_AGAIN_TODAY,
|
name=tr.browsing_again_today(),
|
||||||
icon=icon,
|
icon=icon,
|
||||||
type=type,
|
type=type,
|
||||||
search_node=SearchNode(
|
search_node=SearchNode(
|
||||||
|
@ -816,7 +807,7 @@ class SidebarTreeView(QTreeView):
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
root.add_simple(
|
root.add_simple(
|
||||||
name=TR.BROWSING_SIDEBAR_OVERDUE,
|
name=tr.browsing_sidebar_overdue(),
|
||||||
icon=icon,
|
icon=icon,
|
||||||
type=type,
|
type=type,
|
||||||
search_node=self.col.group_searches(
|
search_node=self.col.group_searches(
|
||||||
|
@ -832,7 +823,7 @@ class SidebarTreeView(QTreeView):
|
||||||
icon = ColoredIcon(path=":/icons/card-state.svg", color=colors.DISABLED)
|
icon = ColoredIcon(path=":/icons/card-state.svg", color=colors.DISABLED)
|
||||||
root = self._section_root(
|
root = self._section_root(
|
||||||
root=root,
|
root=root,
|
||||||
name=TR.BROWSING_SIDEBAR_CARD_STATE,
|
name=tr.browsing_sidebar_card_state(),
|
||||||
icon=icon,
|
icon=icon,
|
||||||
collapse_key=Config.Bool.COLLAPSE_CARD_STATE,
|
collapse_key=Config.Bool.COLLAPSE_CARD_STATE,
|
||||||
type=SidebarItemType.CARD_STATE_ROOT,
|
type=SidebarItemType.CARD_STATE_ROOT,
|
||||||
|
@ -840,32 +831,32 @@ class SidebarTreeView(QTreeView):
|
||||||
type = SidebarItemType.CARD_STATE
|
type = SidebarItemType.CARD_STATE
|
||||||
|
|
||||||
root.add_simple(
|
root.add_simple(
|
||||||
TR.ACTIONS_NEW,
|
tr.actions_new(),
|
||||||
icon=icon.with_color(colors.NEW_COUNT),
|
icon=icon.with_color(colors.NEW_COUNT),
|
||||||
type=type,
|
type=type,
|
||||||
search_node=SearchNode(card_state=SearchNode.CARD_STATE_NEW),
|
search_node=SearchNode(card_state=SearchNode.CARD_STATE_NEW),
|
||||||
)
|
)
|
||||||
|
|
||||||
root.add_simple(
|
root.add_simple(
|
||||||
name=TR.SCHEDULING_LEARNING,
|
name=tr.scheduling_learning(),
|
||||||
icon=icon.with_color(colors.LEARN_COUNT),
|
icon=icon.with_color(colors.LEARN_COUNT),
|
||||||
type=type,
|
type=type,
|
||||||
search_node=SearchNode(card_state=SearchNode.CARD_STATE_LEARN),
|
search_node=SearchNode(card_state=SearchNode.CARD_STATE_LEARN),
|
||||||
)
|
)
|
||||||
root.add_simple(
|
root.add_simple(
|
||||||
name=TR.SCHEDULING_REVIEW,
|
name=tr.scheduling_review(),
|
||||||
icon=icon.with_color(colors.REVIEW_COUNT),
|
icon=icon.with_color(colors.REVIEW_COUNT),
|
||||||
type=type,
|
type=type,
|
||||||
search_node=SearchNode(card_state=SearchNode.CARD_STATE_REVIEW),
|
search_node=SearchNode(card_state=SearchNode.CARD_STATE_REVIEW),
|
||||||
)
|
)
|
||||||
root.add_simple(
|
root.add_simple(
|
||||||
name=TR.BROWSING_SUSPENDED,
|
name=tr.browsing_suspended(),
|
||||||
icon=icon.with_color(colors.SUSPENDED_FG),
|
icon=icon.with_color(colors.SUSPENDED_FG),
|
||||||
type=type,
|
type=type,
|
||||||
search_node=SearchNode(card_state=SearchNode.CARD_STATE_SUSPENDED),
|
search_node=SearchNode(card_state=SearchNode.CARD_STATE_SUSPENDED),
|
||||||
)
|
)
|
||||||
root.add_simple(
|
root.add_simple(
|
||||||
name=TR.BROWSING_BURIED,
|
name=tr.browsing_buried(),
|
||||||
icon=icon.with_color(colors.BURIED_FG),
|
icon=icon.with_color(colors.BURIED_FG),
|
||||||
type=type,
|
type=type,
|
||||||
search_node=SearchNode(card_state=SearchNode.CARD_STATE_BURIED),
|
search_node=SearchNode(card_state=SearchNode.CARD_STATE_BURIED),
|
||||||
|
@ -878,7 +869,7 @@ class SidebarTreeView(QTreeView):
|
||||||
icon = ColoredIcon(path=":/icons/flag.svg", color=colors.DISABLED)
|
icon = ColoredIcon(path=":/icons/flag.svg", color=colors.DISABLED)
|
||||||
root = self._section_root(
|
root = self._section_root(
|
||||||
root=root,
|
root=root,
|
||||||
name=TR.BROWSING_SIDEBAR_FLAGS,
|
name=tr.browsing_sidebar_flags(),
|
||||||
icon=icon,
|
icon=icon,
|
||||||
collapse_key=Config.Bool.COLLAPSE_FLAGS,
|
collapse_key=Config.Bool.COLLAPSE_FLAGS,
|
||||||
type=SidebarItemType.FLAG_ROOT,
|
type=SidebarItemType.FLAG_ROOT,
|
||||||
|
@ -887,31 +878,31 @@ class SidebarTreeView(QTreeView):
|
||||||
|
|
||||||
type = SidebarItemType.FLAG
|
type = SidebarItemType.FLAG
|
||||||
root.add_simple(
|
root.add_simple(
|
||||||
TR.ACTIONS_RED_FLAG,
|
tr.actions_red_flag(),
|
||||||
icon=icon.with_color(colors.FLAG1_FG),
|
icon=icon.with_color(colors.FLAG1_FG),
|
||||||
type=type,
|
type=type,
|
||||||
search_node=SearchNode(flag=SearchNode.FLAG_RED),
|
search_node=SearchNode(flag=SearchNode.FLAG_RED),
|
||||||
)
|
)
|
||||||
root.add_simple(
|
root.add_simple(
|
||||||
TR.ACTIONS_ORANGE_FLAG,
|
tr.actions_orange_flag(),
|
||||||
icon=icon.with_color(colors.FLAG2_FG),
|
icon=icon.with_color(colors.FLAG2_FG),
|
||||||
type=type,
|
type=type,
|
||||||
search_node=SearchNode(flag=SearchNode.FLAG_ORANGE),
|
search_node=SearchNode(flag=SearchNode.FLAG_ORANGE),
|
||||||
)
|
)
|
||||||
root.add_simple(
|
root.add_simple(
|
||||||
TR.ACTIONS_GREEN_FLAG,
|
tr.actions_green_flag(),
|
||||||
icon=icon.with_color(colors.FLAG3_FG),
|
icon=icon.with_color(colors.FLAG3_FG),
|
||||||
type=type,
|
type=type,
|
||||||
search_node=SearchNode(flag=SearchNode.FLAG_GREEN),
|
search_node=SearchNode(flag=SearchNode.FLAG_GREEN),
|
||||||
)
|
)
|
||||||
root.add_simple(
|
root.add_simple(
|
||||||
TR.ACTIONS_BLUE_FLAG,
|
tr.actions_blue_flag(),
|
||||||
icon=icon.with_color(colors.FLAG4_FG),
|
icon=icon.with_color(colors.FLAG4_FG),
|
||||||
type=type,
|
type=type,
|
||||||
search_node=SearchNode(flag=SearchNode.FLAG_BLUE),
|
search_node=SearchNode(flag=SearchNode.FLAG_BLUE),
|
||||||
)
|
)
|
||||||
root.add_simple(
|
root.add_simple(
|
||||||
TR.BROWSING_NO_FLAG,
|
tr.browsing_no_flag(),
|
||||||
icon=icon.with_color(colors.DISABLED),
|
icon=icon.with_color(colors.DISABLED),
|
||||||
type=type,
|
type=type,
|
||||||
search_node=SearchNode(flag=SearchNode.FLAG_NONE),
|
search_node=SearchNode(flag=SearchNode.FLAG_NONE),
|
||||||
|
@ -950,7 +941,7 @@ class SidebarTreeView(QTreeView):
|
||||||
tree = self.col.tags.tree()
|
tree = self.col.tags.tree()
|
||||||
root = self._section_root(
|
root = self._section_root(
|
||||||
root=root,
|
root=root,
|
||||||
name=TR.BROWSING_SIDEBAR_TAGS,
|
name=tr.browsing_sidebar_tags(),
|
||||||
icon=icon,
|
icon=icon,
|
||||||
collapse_key=Config.Bool.COLLAPSE_TAGS,
|
collapse_key=Config.Bool.COLLAPSE_TAGS,
|
||||||
type=SidebarItemType.TAG_ROOT,
|
type=SidebarItemType.TAG_ROOT,
|
||||||
|
@ -997,7 +988,7 @@ class SidebarTreeView(QTreeView):
|
||||||
tree = self.col.decks.deck_tree()
|
tree = self.col.decks.deck_tree()
|
||||||
root = self._section_root(
|
root = self._section_root(
|
||||||
root=root,
|
root=root,
|
||||||
name=TR.BROWSING_SIDEBAR_DECKS,
|
name=tr.browsing_sidebar_decks(),
|
||||||
icon=icon,
|
icon=icon,
|
||||||
collapse_key=Config.Bool.COLLAPSE_DECKS,
|
collapse_key=Config.Bool.COLLAPSE_DECKS,
|
||||||
type=SidebarItemType.DECK_ROOT,
|
type=SidebarItemType.DECK_ROOT,
|
||||||
|
@ -1020,7 +1011,7 @@ class SidebarTreeView(QTreeView):
|
||||||
icon = ":/icons/notetype.svg"
|
icon = ":/icons/notetype.svg"
|
||||||
root = self._section_root(
|
root = self._section_root(
|
||||||
root=root,
|
root=root,
|
||||||
name=TR.BROWSING_SIDEBAR_NOTETYPES,
|
name=tr.browsing_sidebar_notetypes(),
|
||||||
icon=icon,
|
icon=icon,
|
||||||
collapse_key=Config.Bool.COLLAPSE_NOTETYPES,
|
collapse_key=Config.Bool.COLLAPSE_NOTETYPES,
|
||||||
type=SidebarItemType.NOTETYPE_ROOT,
|
type=SidebarItemType.NOTETYPE_ROOT,
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
import anki.lang
|
import anki.lang
|
||||||
from anki.lang import TR
|
|
||||||
|
|
||||||
|
|
||||||
def test_no_collection_i18n():
|
def test_no_collection_i18n():
|
||||||
anki.lang.set_lang("zz")
|
anki.lang.set_lang("zz")
|
||||||
tr2 = anki.lang.current_i18n.translate
|
tr = anki.lang.tr_legacyglobal
|
||||||
no_uni = anki.lang.without_unicode_isolation
|
no_uni = anki.lang.without_unicode_isolation
|
||||||
assert no_uni(tr2(TR.STATISTICS_REVIEWS, reviews=2)) == "2 reviews"
|
assert no_uni(tr.statistics_reviews(reviews=2)) == "2 reviews"
|
||||||
|
|
||||||
anki.lang.set_lang("ja")
|
anki.lang.set_lang("ja")
|
||||||
tr2 = anki.lang.current_i18n.translate
|
assert no_uni(tr.statistics_reviews(reviews=2)) == "2 枚の復習カード"
|
||||||
assert no_uni(tr2(TR.STATISTICS_REVIEWS, reviews=2)) == "2 枚の復習カード"
|
|
||||||
|
|
Loading…
Reference in a new issue