Mark translated posts

main
Bob Mottram 2021-07-20 12:21:15 +01:00
parent fc20b17ea5
commit aa0a176ebf
19 changed files with 48 additions and 23 deletions

View File

@ -256,7 +256,7 @@ def _libretranslate(url: str, text: str,
def autoTranslatePost(baseDir: str, postJsonObject: {},
systemLanguage: str) -> str:
systemLanguage: str, translate: {}) -> str:
"""Tries to automatically translate the given post
"""
if not hasObjectDict(postJsonObject):
@ -276,8 +276,14 @@ def autoTranslatePost(baseDir: str, postJsonObject: {},
_libretranslateLanguages(libretranslateUrl, libretranslateApiKey)
for lang in langList:
if msgObject['contentMap'].get(lang):
return _libretranslate(libretranslateUrl,
msgObject['contentMap']['lang'],
lang, systemLanguage,
libretranslateApiKey)
translatedText = \
_libretranslate(libretranslateUrl,
msgObject['contentMap']['lang'],
lang, systemLanguage,
libretranslateApiKey)
if translatedText:
translatedText = \
'<p>' + translate['Translated'].upper() + '</p>' + \
translatedText
return translatedText
return ''

View File

@ -451,5 +451,6 @@
"Custom post submit button text": "عرف نشر إرسال نص زر",
"Blocked User Agents": "عوامل المستخدم المحظورة",
"Notify me when this account posts": "أعلمني عندما ينشر الحساب هذا",
"Languages": "اللغات"
"Languages": "اللغات",
"Translated": "تترجم"
}

View File

@ -451,5 +451,6 @@
"Custom post submit button text": "Text de botó d'enviament de publicacions personalitzades",
"Blocked User Agents": "Agents d'usuari bloquejats",
"Notify me when this account posts": "Aviseu-me quan publiqui aquest compte",
"Languages": "Idiomes"
"Languages": "Idiomes",
"Translated": "Traduït"
}

View File

@ -451,5 +451,6 @@
"Custom post submit button text": "Testun Post Post Post",
"Blocked User Agents": "Asiantau defnyddwyr wedi'u blocio",
"Notify me when this account posts": "Rhoi gwybod i mi pan fydd y cyfrifon cyfrif hwn",
"Languages": "Ieithoedd"
"Languages": "Ieithoedd",
"Translated": "Chyfieithwyd"
}

View File

@ -451,5 +451,6 @@
"Custom post submit button text": "Benutzerdefinierte Post-Senden Schaltfläche Text",
"Blocked User Agents": "Blockierte Benutzeragenten",
"Notify me when this account posts": "Benachrichtigen Sie mich, wenn dieses Konto postet",
"Languages": "Sprachen"
"Languages": "Sprachen",
"Translated": "Übersetzt"
}

View File

@ -451,5 +451,6 @@
"Custom post submit button text": "Custom post submit button text",
"Blocked User Agents": "Blocked User Agents",
"Notify me when this account posts": "Notify me when this account posts",
"Languages": "Languages"
"Languages": "Languages",
"Translated": "Translated"
}

View File

@ -451,5 +451,6 @@
"Custom post submit button text": "POST POST PERSONALIZADO Botón Texto",
"Blocked User Agents": "Agentes de usuario bloqueados",
"Notify me when this account posts": "Notifíqueme cuando se publique esta cuenta",
"Languages": "Idiomas"
"Languages": "Idiomas",
"Translated": "Traducida"
}

View File

@ -451,5 +451,6 @@
"Custom post submit button text": "Texte de bouton d'envoi postal personnalisé",
"Blocked User Agents": "Agents d'utilisateur bloqués",
"Notify me when this account posts": "Avertissez-moi quand ce compte publie",
"Languages": "Langues"
"Languages": "Langues",
"Translated": "Traduite"
}

View File

@ -451,5 +451,6 @@
"Custom post submit button text": "Post saincheaptha Cuir isteach an cnaipe Téacs",
"Blocked User Agents": "Gníomhairí úsáideora blocáilte",
"Notify me when this account posts": "Cuir in iúl dom nuair a phostófar an cuntas seo",
"Languages": "Teangacha"
"Languages": "Teangacha",
"Translated": "Aistrithe"
}

View File

@ -451,5 +451,6 @@
"Custom post submit button text": "कस्टम पोस्ट सबमिट बटन टेक्स्ट",
"Blocked User Agents": "अवरुद्ध उपयोगकर्ता एजेंट",
"Notify me when this account posts": "यह खाता पोस्ट होने पर मुझे सूचित करें",
"Languages": "बोली"
"Languages": "बोली",
"Translated": "अनुवाद"
}

View File

@ -451,5 +451,6 @@
"Custom post submit button text": "Pulsante di invio del post personalizzato",
"Blocked User Agents": "Agenti utente bloccati",
"Notify me when this account posts": "Avvisami quando questo account messaggi",
"Languages": "Le lingue"
"Languages": "Le lingue",
"Translated": "Tradotto"
}

View File

@ -451,5 +451,6 @@
"Custom post submit button text": "カスタムポスト送信ボタンテキスト",
"Blocked User Agents": "ブロックされたユーザーエージェント",
"Notify me when this account posts": "この口座投稿を通知する",
"Languages": "言語"
"Languages": "言語",
"Translated": "翻訳"
}

View File

@ -451,5 +451,6 @@
"Custom post submit button text": "Nivîsa bişkojka paşîn a paşîn",
"Blocked User Agents": "Karmendên bikarhêner asteng kirin",
"Notify me when this account posts": "Dema ku ev postên hesabê min agahdar bikin",
"Languages": "Ziman"
"Languages": "Ziman",
"Translated": "Wergerandin"
}

View File

@ -447,5 +447,6 @@
"Custom post submit button text": "Custom post submit button text",
"Blocked User Agents": "Blocked User Agents",
"Notify me when this account posts": "Notify me when this account posts",
"Languages": "Languages"
"Languages": "Languages",
"Translated": "Translated"
}

View File

@ -451,5 +451,6 @@
"Custom post submit button text": "Texto de botão de envio de post personalizado",
"Blocked User Agents": "Agentes de usuário bloqueados",
"Notify me when this account posts": "Notifique-me quando esta conta posts",
"Languages": "Línguas"
"Languages": "Línguas",
"Translated": "Traduzida"
}

View File

@ -451,5 +451,6 @@
"Custom post submit button text": "Пользовательский пост Отправить кнопку текста",
"Blocked User Agents": "Заблокированные пользовательские агенты",
"Notify me when this account posts": "Сообщите мне, когда эта учетная запись",
"Languages": "Языки"
"Languages": "Языки",
"Translated": "Перевод"
}

View File

@ -451,5 +451,6 @@
"Custom post submit button text": "Ujumbe wa Desturi Wasilisha Nakala ya kifungo",
"Blocked User Agents": "Wakala wa watumiaji waliozuiwa",
"Notify me when this account posts": "Nijulishe wakati akaunti hii ya akaunti.",
"Languages": "Lugha"
"Languages": "Lugha",
"Translated": "Ilitafsiriwa"
}

View File

@ -451,5 +451,6 @@
"Custom post submit button text": "自定义发布提交按钮文本",
"Blocked User Agents": "阻止用户代理商",
"Notify me when this account posts": "此帐户帖子时通知我",
"Languages": "语言"
"Languages": "语言",
"Translated": "翻译"
}

View File

@ -1594,7 +1594,9 @@ def individualPostAsHtml(allowDownloads: bool,
contentStr = getContentFromPost(postJsonObject, systemLanguage)
if not contentStr:
contentStr = autoTranslatePost(baseDir, postJsonObject, systemLanguage)
contentStr = \
autoTranslatePost(baseDir, postJsonObject,
systemLanguage, translate)
if not contentStr:
return ''