avatar Bite 213. Code a translation fixer

Imagine you built PyBites' new translation feature. You managed to successfully get translated text for a Bite, but there's a problem: the Python code inside the HTML code and pre tags gets translated too (yes, this actually happened to us!). Nobody ever said developer life was going to be easy right? (chuckle)

As we code in English, we require all code snippets to be in English even if the overall Bite description is being translated to another language.

Luckily, by now, you've mastered some text manipulation and regex skills (this is an advanced Bite after all) so you will write some code to fix this for all future translation calls.

Here is a small example (we test 3 different ones in the associated tests):

Original English Bite text:

original English Bite text

Translator output which translated everything, description and code, to Russian:

result of translator call

You will take both output instances and produce the desired output: the description is in Russian while the code content in the code and pre tags is left intact (English):

translation text fixed by your code

Good luck and keep calm and code in Python.

Login and get coding
go back Advanced level
Bitecoin 4X

Will you be Pythonista #108 to crack this Bite?
Resolution time: ~73 min. (avg. submissions of 5-240 min.)
Pythonistas rate this Bite 5.6 on a 1-10 difficulty scale.
» Up for a challenge? 💪

Focus on this Bite hiding sidebars, turn on Focus Mode.

Ask for Help