Skip to content

Commit

Permalink
[zh] don't extract other translation subpage in translation subpage
Browse files Browse the repository at this point in the history
Fix `RecursionError` in page "兄弟", maybe triggered by disabling
analyze template feature.
  • Loading branch information
xxyzz committed Aug 26, 2024
1 parent 6118d68 commit 7a5849e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/wiktextract/extractor/zh/translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def extract_translation(
page_data: list[WordEntry],
level_node: WikiNode,
sense: str = "",
is_subpage: bool = False,
) -> None:
for child in level_node.find_child(NodeKind.TEMPLATE | NodeKind.LIST):
if isinstance(child, TemplateNode):
Expand All @@ -29,7 +30,10 @@ def extract_translation(
and 1 in child.template_parameters
):
sense = clean_node(wxr, None, child.template_parameters.get(1))
elif template_name in {"see translation subpage", "trans-see"}:
elif (
template_name in {"see translation subpage", "trans-see"}
and not is_subpage
):
translation_subpage(wxr, page_data, child)
elif template_name == "multitrans":
wikitext = "".join(
Expand Down Expand Up @@ -176,7 +180,7 @@ def translation_subpage(
)
translation_node = find_subpage_section(wxr, target_section_node)
if translation_node is not None:
extract_translation(wxr, page_data, translation_node)
extract_translation(wxr, page_data, translation_node, is_subpage=True)


def find_subpage_section(
Expand Down

0 comments on commit 7a5849e

Please sign in to comment.