mirror of https://gitlab.com/bashrc2/epicyon
Snake case
parent
d177997063
commit
d90fd16128
6
blog.py
6
blog.py
|
@ -268,11 +268,11 @@ def _htmlBlogPostContent(debug: bool, session, authorized: bool,
|
||||||
personUrl = local_actor_url(http_prefix, nickname, domain_full)
|
personUrl = local_actor_url(http_prefix, nickname, domain_full)
|
||||||
actor_json = \
|
actor_json = \
|
||||||
getPersonFromCache(base_dir, personUrl, person_cache, False)
|
getPersonFromCache(base_dir, personUrl, person_cache, False)
|
||||||
languagesUnderstood = []
|
languages_understood = []
|
||||||
if actor_json:
|
if actor_json:
|
||||||
languagesUnderstood = get_actor_languages_list(actor_json)
|
languages_understood = get_actor_languages_list(actor_json)
|
||||||
jsonContent = get_content_from_post(post_json_object, system_language,
|
jsonContent = get_content_from_post(post_json_object, system_language,
|
||||||
languagesUnderstood)
|
languages_understood)
|
||||||
if jsonContent:
|
if jsonContent:
|
||||||
contentStr = addEmbeddedElements(translate, jsonContent,
|
contentStr = addEmbeddedElements(translate, jsonContent,
|
||||||
peertube_instances)
|
peertube_instances)
|
||||||
|
|
|
@ -111,10 +111,10 @@ def understoodPostLanguage(base_dir: str, nickname: str, domain: str,
|
||||||
if not actor_json:
|
if not actor_json:
|
||||||
print('WARN: unable to load actor to check languages ' + personUrl)
|
print('WARN: unable to load actor to check languages ' + personUrl)
|
||||||
return False
|
return False
|
||||||
languagesUnderstood = get_actor_languages_list(actor_json)
|
languages_understood = get_actor_languages_list(actor_json)
|
||||||
if not languagesUnderstood:
|
if not languages_understood:
|
||||||
return True
|
return True
|
||||||
for lang in languagesUnderstood:
|
for lang in languages_understood:
|
||||||
if msgObject['contentMap'].get(lang):
|
if msgObject['contentMap'].get(lang):
|
||||||
return True
|
return True
|
||||||
# is the language for this post supported by libretranslate?
|
# is the language for this post supported by libretranslate?
|
||||||
|
|
4
utils.py
4
utils.py
|
@ -78,7 +78,7 @@ def get_actor_languages_list(actor_json: {}) -> []:
|
||||||
|
|
||||||
|
|
||||||
def get_content_from_post(post_json_object: {}, system_language: str,
|
def get_content_from_post(post_json_object: {}, system_language: str,
|
||||||
languagesUnderstood: []) -> str:
|
languages_understood: []) -> str:
|
||||||
"""Returns the content from the post in the given language
|
"""Returns the content from the post in the given language
|
||||||
including searching for a matching entry within contentMap
|
including searching for a matching entry within contentMap
|
||||||
"""
|
"""
|
||||||
|
@ -97,7 +97,7 @@ def get_content_from_post(post_json_object: {}, system_language: str,
|
||||||
else:
|
else:
|
||||||
# is there a contentMap entry for one of
|
# is there a contentMap entry for one of
|
||||||
# the understood languages?
|
# the understood languages?
|
||||||
for lang in languagesUnderstood:
|
for lang in languages_understood:
|
||||||
if thisPostJson['contentMap'].get(lang):
|
if thisPostJson['contentMap'].get(lang):
|
||||||
return thisPostJson['contentMap'][lang]
|
return thisPostJson['contentMap'][lang]
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1852,11 +1852,11 @@ def individualPostAsHtml(signing_priv_key_pem: str,
|
||||||
personUrl = local_actor_url(http_prefix, nickname, domain_full)
|
personUrl = local_actor_url(http_prefix, nickname, domain_full)
|
||||||
actor_json = \
|
actor_json = \
|
||||||
getPersonFromCache(base_dir, personUrl, person_cache, False)
|
getPersonFromCache(base_dir, personUrl, person_cache, False)
|
||||||
languagesUnderstood = []
|
languages_understood = []
|
||||||
if actor_json:
|
if actor_json:
|
||||||
languagesUnderstood = get_actor_languages_list(actor_json)
|
languages_understood = get_actor_languages_list(actor_json)
|
||||||
contentStr = get_content_from_post(post_json_object, system_language,
|
contentStr = get_content_from_post(post_json_object, system_language,
|
||||||
languagesUnderstood)
|
languages_understood)
|
||||||
if not contentStr:
|
if not contentStr:
|
||||||
contentStr = \
|
contentStr = \
|
||||||
autoTranslatePost(base_dir, post_json_object,
|
autoTranslatePost(base_dir, post_json_object,
|
||||||
|
|
Loading…
Reference in New Issue