mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2024-12-18 08:27:03 +02:00
Handle empty translation
This commit is contained in:
parent
b87b210bfc
commit
0478d4ee2c
@ -501,9 +501,9 @@ def create_app(args):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return jsonify(
|
return jsonify(
|
||||||
{
|
{
|
||||||
"translatedText": results
|
"translatedText": results
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
translator = src_langs[0].get_translation(tgt_lang)
|
translator = src_langs[0].get_translation(tgt_lang)
|
||||||
|
@ -81,9 +81,9 @@ def detect_languages(text):
|
|||||||
def improve_translation_formatting(source, translation, improve_punctuation=True):
|
def improve_translation_formatting(source, translation, improve_punctuation=True):
|
||||||
source = source.strip()
|
source = source.strip()
|
||||||
|
|
||||||
if not len(source):
|
if not len(source) or not len(translation):
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
if improve_punctuation:
|
if improve_punctuation:
|
||||||
source_last_char = source[len(source) - 1]
|
source_last_char = source[len(source) - 1]
|
||||||
translation_last_char = translation[len(translation) - 1]
|
translation_last_char = translation[len(translation) - 1]
|
||||||
|
Loading…
Reference in New Issue
Block a user