Skip to content

Commit

Permalink
Fix DummyTranslator test errors with Wagtail 6
Browse files Browse the repository at this point in the history
  • Loading branch information
zerolab committed Feb 10, 2024
1 parent 34d2b4e commit cd6ad7f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions wagtail_localize/machine_translators/dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@ def walk(soup):
if isinstance(child, NavigableString):
# Translate navigable strings
child.string.replace_with(translate_string(child.string))

else:
walk(child)

# Reverse the children
if isinstance(soup, Tag):
soup.contents.reverse()
# reverse the children
reversed_contents = soup.contents[::-1]

soup = BeautifulSoup("", "html.parser")
for content in reversed_contents:
soup.append(content)

walk(soup)

Expand Down

0 comments on commit cd6ad7f

Please sign in to comment.