From eae29d62051072ff1f0b4899260db1e684dcb42e Mon Sep 17 00:00:00 2001 From: Bobby Date: Tue, 6 Jun 2023 21:16:50 -0400 Subject: Accidental Bug Fixed --- middleware/translationMiddleware.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'middleware') diff --git a/middleware/translationMiddleware.py b/middleware/translationMiddleware.py index 21103e21..cfebbbdb 100644 --- a/middleware/translationMiddleware.py +++ b/middleware/translationMiddleware.py @@ -1,4 +1,5 @@ import os +from bs4 import BeautifulSoup from django.http import HttpResponse import redis @@ -38,6 +39,12 @@ class TranslationMiddleware: return response HTML_content =response.content.decode('utf-8') + + # add no translate class to the 'highlight' class + soup = BeautifulSoup(HTML_content, 'html.parser') + for tag in soup.find_all(class_='highlight'): + tag['class'].append('notranslate') + HTML_content = str(soup) HTML_content = HTML_content.replace( "That Computer Scientist", -- cgit v1.2.3