Check if text was translated

main
Bob Mottram 2021-07-20 20:46:44 +01:00
parent 65d2e839a0
commit 7809411a91
1 changed files with 4 additions and 3 deletions

View File

@ -208,7 +208,6 @@ def _libretranslate(url: str, text: str,
source: str, target: str, apiKey: str = None) -> str: source: str, target: str, apiKey: str = None) -> str:
"""Translate string using libretranslate """Translate string using libretranslate
""" """
if not url.endswith('/translate'): if not url.endswith('/translate'):
if not url.endswith('/'): if not url.endswith('/'):
url += "/translate" url += "/translate"
@ -267,11 +266,13 @@ def autoTranslatePost(baseDir: str, postJsonObject: {},
_libretranslateLanguages(libretranslateUrl, libretranslateApiKey) _libretranslateLanguages(libretranslateUrl, libretranslateApiKey)
for lang in langList: for lang in langList:
if msgObject['contentMap'].get(lang): if msgObject['contentMap'].get(lang):
content = msgObject['contentMap'][lang]
translatedText = \ translatedText = \
_libretranslate(libretranslateUrl, _libretranslate(libretranslateUrl, content,
msgObject['contentMap'][lang],
lang, systemLanguage, lang, systemLanguage,
libretranslateApiKey) libretranslateApiKey)
if removeHtml(translatedText) == removeHtml(content):
return content
if translatedText: if translatedText:
translatedText = \ translatedText = \
'<p>' + translate['Translated'].upper() + '</p>' + \ '<p>' + translate['Translated'].upper() + '</p>' + \