mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2024-11-15 12:41:35 +00:00
Revert "improve translation formating"
This commit is contained in:
parent
adebc2a536
commit
5773adaabd
1 changed files with 2 additions and 19 deletions
21
app/app.py
21
app/app.py
|
@ -474,21 +474,6 @@ def create_app(args):
|
||||||
if text_format not in ["text", "html"]:
|
if text_format not in ["text", "html"]:
|
||||||
abort(400, description="%s format is not supported" % text_format)
|
abort(400, description="%s format is not supported" % text_format)
|
||||||
|
|
||||||
def improve_translation(source, translation):
|
|
||||||
if source.islower():
|
|
||||||
return translation.lower()
|
|
||||||
|
|
||||||
if source.isupper():
|
|
||||||
return translation.upper()
|
|
||||||
|
|
||||||
if source[0].islower():
|
|
||||||
return translation[0].lower() + translation[1:]
|
|
||||||
|
|
||||||
if source[0].isupper():
|
|
||||||
return translation[0].upper() + translation[1:]
|
|
||||||
|
|
||||||
return translation
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if batch:
|
if batch:
|
||||||
results = []
|
results = []
|
||||||
|
@ -498,8 +483,7 @@ def create_app(args):
|
||||||
if text_format == "html":
|
if text_format == "html":
|
||||||
translated_text = str(translate_html(translator, text))
|
translated_text = str(translate_html(translator, text))
|
||||||
else:
|
else:
|
||||||
translated_text = improve_translation(text, translator.translate(
|
translated_text = translator.translate(transliterate(text, target_lang=source_langs[idx]["language"]))
|
||||||
transliterate(text, target_lang=source_langs[idx]["language"])))
|
|
||||||
|
|
||||||
results.append(unescape(translated_text))
|
results.append(unescape(translated_text))
|
||||||
if source_lang == "auto":
|
if source_lang == "auto":
|
||||||
|
@ -521,8 +505,7 @@ def create_app(args):
|
||||||
if text_format == "html":
|
if text_format == "html":
|
||||||
translated_text = str(translate_html(translator, q))
|
translated_text = str(translate_html(translator, q))
|
||||||
else:
|
else:
|
||||||
translated_text = improve_translation(q, translator.translate(
|
translated_text = translator.translate(transliterate(q, target_lang=source_langs[0]["language"]))
|
||||||
transliterate(q, target_lang=source_langs[0]["language"])))
|
|
||||||
|
|
||||||
if source_lang == "auto":
|
if source_lang == "auto":
|
||||||
return jsonify(
|
return jsonify(
|
||||||
|
|
Loading…
Reference in a new issue