diff --git a/wagtail_localize/machine_translators/dummy.py b/wagtail_localize/machine_translators/dummy.py index 6fd5a0c4..177d9e31 100644 --- a/wagtail_localize/machine_translators/dummy.py +++ b/wagtail_localize/machine_translators/dummy.py @@ -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)