mirror of https://gitlab.com/bashrc2/epicyon
Check if text was translated
parent
65d2e839a0
commit
7809411a91
|
@ -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>' + \
|
||||||
|
|
Loading…
Reference in New Issue