From cd534ba46e4c4160c0c9a3e5d221dd3669bfd9d1 Mon Sep 17 00:00:00 2001 From: Lu Guanghua <102669562+Touch-Night@users.noreply.github.com> Date: Sat, 16 Sep 2023 21:18:06 +0800 Subject: [PATCH] Fix Google Translate escaping (#3827) --------- Co-authored-by: oobabooga <112222186+oobabooga@users.noreply.github.com> --- extensions/google_translate/script.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/extensions/google_translate/script.py b/extensions/google_translate/script.py index 5dfdbcd0..784668c1 100644 --- a/extensions/google_translate/script.py +++ b/extensions/google_translate/script.py @@ -1,3 +1,5 @@ +import html + import gradio as gr from deep_translator import GoogleTranslator @@ -27,7 +29,8 @@ def output_modifier(string): if not params['activate']: return string - return GoogleTranslator(source='en', target=params['language string']).translate(string) + translated_str = GoogleTranslator(source='en', target=params['language string']).translate(html.unescape(string)) + return html.escape(translated_str) def bot_prefix_modifier(string):