aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBobby <[email protected]>2023-06-06 21:16:50 -0400
committerBobby <[email protected]>2023-06-06 21:16:50 -0400
commiteae29d62051072ff1f0b4899260db1e684dcb42e (patch)
treefd4a4e6827465fdede1bc0eda103d71837347830
parentb429570ec8821ca5f9a82787d7e69923981744a9 (diff)
downloadthatcomputerscientist-eae29d62051072ff1f0b4899260db1e684dcb42e.tar.xz
thatcomputerscientist-eae29d62051072ff1f0b4899260db1e684dcb42e.zip
Accidental Bug Fixed
-rw-r--r--middleware/translationMiddleware.py7
1 files changed, 7 insertions, 0 deletions
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",