Translate the nowplaying hashtag

merge-requests/25/head
Bob Mottram 2022-07-18 17:18:04 +01:00
parent f36fb270a5
commit 297f25f92c
38 changed files with 207 additions and 112 deletions

View File

@ -1151,7 +1151,7 @@ def load_dogwhistles(filename: str) -> {}:
def add_html_tags(base_dir: str, http_prefix: str,
nickname: str, domain: str, content: str,
recipients: [], hashtags: {},
recipients: [], hashtags: {}, translate: {},
is_json_content: bool = False) -> str:
""" Replaces plaintext mentions such as @nick@domain into html
by matching against known following accounts
@ -1162,7 +1162,10 @@ def add_html_tags(base_dir: str, http_prefix: str,
max_word_length = 40
content = content.replace('\r', '')
content = content.replace('\n', ' --linebreak-- ')
content = _add_music_tag(content, 'NowPlaying')
now_playing_str = 'NowPlaying'
if translate.get(now_playing_str):
now_playing_str = translate[now_playing_str]
content = _add_music_tag(content, now_playing_str)
words = _get_simplified_content(content).split(' ')
# remove . for words which are not mentions

View File

@ -565,7 +565,8 @@ class PubServer(BaseHTTPRequestHandler):
conversation_id,
self.server.low_bandwidth,
self.server.content_license_url,
languages_understood)
languages_understood,
self.server.translate)
if message_json:
# name field contains the answer
message_json['object']['name'] = answer
@ -6290,7 +6291,8 @@ class PubServer(BaseHTTPRequestHandler):
http_prefix,
nickname,
domain_full,
bio_str, [], actor_tags)
bio_str, [], actor_tags,
self.server.translate)
if actor_tags:
actor_json['tag'] = []
for _, tag in actor_tags.items():
@ -19049,7 +19051,8 @@ class PubServer(BaseHTTPRequestHandler):
conversation_id,
self.server.low_bandwidth,
self.server.content_license_url,
languages_understood)
languages_understood,
self.server.translate)
if message_json:
if fields['schedulePost']:
return 1
@ -19140,7 +19143,8 @@ class PubServer(BaseHTTPRequestHandler):
conversation_id,
self.server.low_bandwidth,
self.server.content_license_url,
languages_understood)
languages_understood,
self.server.translate)
if message_json:
if fields['schedulePost']:
return 1
@ -19195,7 +19199,9 @@ class PubServer(BaseHTTPRequestHandler):
nickname, self.server.domain,
fields['message'],
mentioned_recipients,
hashtags_dict, True)
hashtags_dict,
self.server.translate,
True)
# replace emoji with unicode
tags = []
for _, tag in hashtags_dict.items():
@ -19303,7 +19309,8 @@ class PubServer(BaseHTTPRequestHandler):
conversation_id,
self.server.low_bandwidth,
self.server.content_license_url,
languages_understood)
languages_understood,
self.server.translate)
if message_json:
if fields['schedulePost']:
return 1
@ -19364,7 +19371,8 @@ class PubServer(BaseHTTPRequestHandler):
conversation_id,
self.server.low_bandwidth,
self.server.content_license_url,
languages_understood)
languages_understood,
self.server.translate)
if message_json:
if fields['schedulePost']:
return 1
@ -19437,7 +19445,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.low_bandwidth,
content_license_url,
languages_understood,
reply_is_chat)
reply_is_chat,
self.server.translate)
if message_json:
if fields['schedulePost']:
return 1
@ -19502,7 +19511,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.low_bandwidth,
self.server.content_license_url,
languages_understood,
False)
False, self.server.translate)
if message_json:
if fields['schedulePost']:
return 1
@ -19546,7 +19555,8 @@ class PubServer(BaseHTTPRequestHandler):
fields['languagesDropdown'],
self.server.low_bandwidth,
self.server.content_license_url,
languages_understood)
languages_understood,
self.server.translate)
if message_json:
if self._post_to_outbox(message_json,
self.server.project_version,
@ -19595,7 +19605,8 @@ class PubServer(BaseHTTPRequestHandler):
fields['languagesDropdown'],
self.server.low_bandwidth,
self.server.content_license_url,
languages_understood)
languages_understood,
self.server.translate)
if message_json:
if self.server.debug:
print('DEBUG: new Question')

View File

@ -464,7 +464,8 @@ def _desktop_reply_to_post(session, post_id: str,
espeak, conversation_id: str,
low_bandwidth: bool,
content_license_url: str,
signing_priv_key_pem: str) -> None:
signing_priv_key_pem: str,
translate: {}) -> None:
"""Use the desktop client to send a reply to the most recent post
"""
if '://' not in post_id:
@ -523,7 +524,7 @@ def _desktop_reply_to_post(session, post_id: str,
system_language, languages_understood,
low_bandwidth, content_license_url,
event_date, event_time, event_end_time, location,
debug, post_id, post_id,
translate, debug, post_id, post_id,
conversation_id, subject) == 0:
say_str = 'Reply sent'
else:
@ -540,7 +541,8 @@ def _desktop_new_post(session,
languages_understood: [],
espeak, low_bandwidth: bool,
content_license_url: str,
signing_priv_key_pem: str) -> None:
signing_priv_key_pem: str,
translate: {}) -> None:
"""Use the desktop client to create a new post
"""
conversation_id = None
@ -596,7 +598,7 @@ def _desktop_new_post(session,
system_language, languages_understood,
low_bandwidth, content_license_url,
event_date, event_time, event_end_time, location,
debug, None, None,
translate, debug, None, None,
conversation_id, subject) == 0:
say_str = 'Post sent'
else:
@ -1188,7 +1190,8 @@ def _desktop_new_dm(session, to_handle: str,
languages_understood: [],
espeak, low_bandwidth: bool,
content_license_url: str,
signing_priv_key_pem: str) -> None:
signing_priv_key_pem: str,
translate: {}) -> None:
"""Use the desktop client to create a new direct message
which can include multiple destination handles
"""
@ -1212,7 +1215,7 @@ def _desktop_new_dm(session, to_handle: str,
languages_understood,
espeak, low_bandwidth,
content_license_url,
signing_priv_key_pem)
signing_priv_key_pem, translate)
def _desktop_new_dm_base(session, to_handle: str,
@ -1224,7 +1227,8 @@ def _desktop_new_dm_base(session, to_handle: str,
languages_understood: [],
espeak, low_bandwidth: bool,
content_license_url: str,
signing_priv_key_pem: str) -> None:
signing_priv_key_pem: str,
translate: {}) -> None:
"""Use the desktop client to create a new direct message
"""
conversation_id = None
@ -1323,7 +1327,7 @@ def _desktop_new_dm_base(session, to_handle: str,
system_language, languages_understood,
low_bandwidth, content_license_url,
event_date, event_time, event_end_time, location,
debug, None, None,
translate, debug, None, None,
conversation_id, subject) == 0:
say_str = 'Direct message sent'
else:
@ -1791,7 +1795,8 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
espeak, conversation_id,
low_bandwidth,
content_license_url,
signing_priv_key_pem)
signing_priv_key_pem,
translate)
refresh_timeline = True
print('')
elif (command_str == 'post' or command_str == 'p' or
@ -1828,7 +1833,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
languages_understood,
espeak, low_bandwidth,
content_license_url,
signing_priv_key_pem)
signing_priv_key_pem, translate)
refresh_timeline = True
else:
# public post
@ -1841,7 +1846,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
languages_understood,
espeak, low_bandwidth,
content_license_url,
signing_priv_key_pem)
signing_priv_key_pem, translate)
refresh_timeline = True
print('')
elif command_str == 'like' or command_str.startswith('like '):

View File

@ -1546,6 +1546,7 @@ def _command_options() -> None:
languages_understood = [argb.language]
if argb.languages_understood:
languages_understood = [argb.languages_understood]
translate = {}
print('Sending post to ' + argb.sendto)
send_post_via_server(signing_priv_key_pem, __version__,
@ -1560,7 +1561,7 @@ def _command_options() -> None:
argb.low_bandwidth,
argb.content_license_url,
argb.eventDate, argb.eventTime, argb.eventEndTime,
argb.eventLocation,
argb.eventLocation, translate,
argb.debug,
reply_to, reply_to, argb.conversationId, subject)
for _ in range(10):
@ -3217,6 +3218,7 @@ def _command_options() -> None:
conversation_id = None
low_bandwidth = False
languages_understood = [argb.language]
translate = {}
create_public_post(base_dir, nickname, domain, port, http_prefix,
"like this is totally just a #test man",
@ -3231,7 +3233,7 @@ def _command_options() -> None:
test_event_end_time, test_location,
test_is_article, argb.language, conversation_id,
low_bandwidth, argb.content_license_url,
languages_understood)
languages_understood, translate)
create_public_post(base_dir, nickname, domain, port, http_prefix,
"Zoiks!!!",
test_save_to_file,
@ -3245,7 +3247,7 @@ def _command_options() -> None:
test_event_end_time, test_location,
test_is_article, argb.language, conversation_id,
low_bandwidth, argb.content_license_url,
languages_understood)
languages_understood, translate)
create_public_post(base_dir, nickname, domain, port, http_prefix,
"Hey scoob we need like a hundred more #milkshakes",
test_save_to_file,
@ -3259,7 +3261,7 @@ def _command_options() -> None:
test_event_end_time, test_location,
test_is_article, argb.language, conversation_id,
low_bandwidth, argb.content_license_url,
languages_understood)
languages_understood, translate)
create_public_post(base_dir, nickname, domain, port, http_prefix,
"Getting kinda spooky around here",
test_save_to_file,
@ -3273,7 +3275,7 @@ def _command_options() -> None:
test_event_end_time, test_location,
test_is_article, argb.language, conversation_id,
low_bandwidth, argb.content_license_url,
languages_understood)
languages_understood, translate)
create_public_post(base_dir, nickname, domain, port, http_prefix,
"And they would have gotten away with it too" +
"if it wasn't for those pesky hackers",
@ -3288,7 +3290,7 @@ def _command_options() -> None:
test_event_end_time, test_location,
test_is_article, argb.language, conversation_id,
low_bandwidth, argb.content_license_url,
languages_understood)
languages_understood, translate)
create_public_post(base_dir, nickname, domain, port, http_prefix,
"man these centralized sites are like the worst!",
test_save_to_file,
@ -3302,7 +3304,7 @@ def _command_options() -> None:
test_event_end_time, test_location,
test_is_article, argb.language, conversation_id,
low_bandwidth, argb.content_license_url,
languages_understood)
languages_understood, translate)
create_public_post(base_dir, nickname, domain, port, http_prefix,
"another mystery solved #test",
test_save_to_file,
@ -3316,7 +3318,7 @@ def _command_options() -> None:
test_event_end_time, test_location,
test_is_article, argb.language, conversation_id,
low_bandwidth, argb.content_license_url,
languages_understood)
languages_understood, translate)
create_public_post(base_dir, nickname, domain, port, http_prefix,
"let's go bowling",
test_save_to_file,
@ -3330,7 +3332,7 @@ def _command_options() -> None:
test_event_end_time, test_location,
test_is_article, argb.language, conversation_id,
low_bandwidth, argb.content_license_url,
languages_understood)
languages_understood, translate)
domain_full = domain + ':' + str(port)
clear_follows(base_dir, nickname, domain)
follow_person(base_dir, nickname, domain, 'maxboardroom', domain_full,

View File

@ -3319,7 +3319,8 @@ def _bounce_dm(sender_post_id: str, session, http_prefix: str,
location, system_language, conversation_id,
low_bandwidth,
content_license_url,
languages_understood, bounce_is_chat)
languages_understood, bounce_is_chat,
translate)
if not post_json_object:
print('WARN: unable to create bounce message to ' + sending_handle)
return False

View File

@ -643,7 +643,7 @@ def _convert_rss_to_activitypub(base_dir: str, http_prefix: str,
rss_title, system_language,
conversation_id, low_bandwidth,
content_license_url,
languages_understood)
languages_understood, translate)
if not blog:
continue

View File

@ -198,8 +198,8 @@ def _capitalize_hashtag(content: str, message_json: {},
"""
if translate.get(original_tag) and \
translate.get(capitalized_tag):
original_tag = translate[original_tag]
capitalized_tag = translate[capitalized_tag]
original_tag = translate[original_tag].replace(' ', '_')
capitalized_tag = translate[capitalized_tag].replace(' ', '_')
if '#' + original_tag not in content:
return

View File

@ -1425,7 +1425,7 @@ def _create_post_base(base_dir: str,
system_language: str,
conversation_id: str, low_bandwidth: bool,
content_license_url: str,
languages_understood: []) -> {}:
languages_understood: [], translate: {}) -> {}:
"""Creates a message
"""
content = remove_invalid_chars(content)
@ -1470,7 +1470,7 @@ def _create_post_base(base_dir: str,
add_html_tags(base_dir, http_prefix,
nickname, domain, content,
mentioned_recipients,
hashtags_dict, True)
hashtags_dict, translate, True)
# replace emoji with unicode
tags = []
@ -1837,7 +1837,7 @@ def create_public_post(base_dir: str,
location: str, is_article: bool, system_language: str,
conversation_id: str, low_bandwidth: bool,
content_license_url: str,
languages_understood: []) -> {}:
languages_understood: [], translate: {}) -> {}:
"""Public post
"""
domain_full = get_full_domain(domain, port)
@ -1871,7 +1871,7 @@ def create_public_post(base_dir: str,
event_status, ticket_url, system_language,
conversation_id, low_bandwidth,
content_license_url,
languages_understood)
languages_understood, translate)
def _append_citations_to_blog_post(base_dir: str,
@ -1916,7 +1916,7 @@ def create_blog_post(base_dir: str,
location: str, system_language: str,
conversation_id: str, low_bandwidth: bool,
content_license_url: str,
languages_understood: []) -> {}:
languages_understood: [], translate: {}) -> {}:
blog_json = \
create_public_post(base_dir,
nickname, domain, port, http_prefix,
@ -1929,7 +1929,7 @@ def create_blog_post(base_dir: str,
event_date, event_time, event_end_time, location,
True, system_language, conversation_id,
low_bandwidth, content_license_url,
languages_understood)
languages_understood, translate)
blog_json['object']['url'] = \
blog_json['object']['url'].replace('/@', '/users/')
_append_citations_to_blog_post(base_dir, nickname, domain, blog_json)
@ -1945,7 +1945,7 @@ def create_news_post(base_dir: str,
subject: str, system_language: str,
conversation_id: str, low_bandwidth: bool,
content_license_url: str,
languages_understood: []) -> {}:
languages_understood: [], translate: {}) -> {}:
client_to_server = False
in_reply_to = None
in_reply_to_atom_uri = None
@ -1966,7 +1966,7 @@ def create_news_post(base_dir: str,
event_date, event_time, event_end_time, location,
True, system_language, conversation_id,
low_bandwidth, content_license_url,
languages_understood)
languages_understood, translate)
blog['object']['type'] = 'Article'
return blog
@ -1982,7 +1982,7 @@ def create_question_post(base_dir: str,
subject: str, duration_days: int,
system_language: str, low_bandwidth: bool,
content_license_url: str,
languages_understood: []) -> {}:
languages_understood: [], translate: {}) -> {}:
"""Question post with multiple choice options
"""
domain_full = get_full_domain(domain, port)
@ -2000,7 +2000,7 @@ def create_question_post(base_dir: str,
None, None, None,
None, None, None, None, None, system_language,
None, low_bandwidth, content_license_url,
languages_understood)
languages_understood, translate)
message_json['object']['type'] = 'Question'
message_json['object']['oneOf'] = []
message_json['object']['votersCount'] = 0
@ -2035,7 +2035,7 @@ def create_unlisted_post(base_dir: str,
location: str, system_language: str,
conversation_id: str, low_bandwidth: bool,
content_license_url: str,
languages_understood: []) -> {}:
languages_understood: [], translate: {}) -> {}:
"""Unlisted post. This has the #Public and followers links inverted.
"""
domain_full = get_full_domain(domain, port)
@ -2054,7 +2054,8 @@ def create_unlisted_post(base_dir: str,
None, None, None, event_date, event_end_time,
None, None, None, None, None, system_language,
conversation_id, low_bandwidth,
content_license_url, languages_understood)
content_license_url, languages_understood,
translate)
def create_followers_only_post(base_dir: str,
@ -2072,7 +2073,8 @@ def create_followers_only_post(base_dir: str,
location: str, system_language: str,
conversation_id: str, low_bandwidth: bool,
content_license_url: str,
languages_understood: []) -> {}:
languages_understood: [],
translate: {}) -> {}:
"""Followers only post
"""
domain_full = get_full_domain(domain, port)
@ -2089,7 +2091,8 @@ def create_followers_only_post(base_dir: str,
None, None, None, event_date, event_end_time,
None, None, None, None, None, system_language,
conversation_id, low_bandwidth,
content_license_url, languages_understood)
content_license_url, languages_understood,
translate)
def get_mentioned_people(base_dir: str, http_prefix: str,
@ -2145,7 +2148,7 @@ def create_direct_message_post(base_dir: str,
conversation_id: str, low_bandwidth: bool,
content_license_url: str,
languages_understood: [],
dm_is_chat: bool) -> {}:
dm_is_chat: bool, translate: {}) -> {}:
"""Direct Message post
"""
content = resolve_petnames(base_dir, nickname, domain, content)
@ -2170,7 +2173,8 @@ def create_direct_message_post(base_dir: str,
None, None, None, event_date, event_end_time,
None, None, None, None, None, system_language,
conversation_id, low_bandwidth,
content_license_url, languages_understood)
content_license_url, languages_understood,
translate)
# mentioned recipients go into To rather than Cc
message_json['to'] = message_json['object']['cc']
message_json['object']['to'] = message_json['to']
@ -2194,7 +2198,7 @@ def create_report_post(base_dir: str,
debug: bool, subject: str, system_language: str,
low_bandwidth: bool,
content_license_url: str,
languages_understood: []) -> {}:
languages_understood: [], translate: {}) -> {}:
"""Send a report to moderators
"""
domain_full = get_full_domain(domain, port)
@ -2273,7 +2277,7 @@ def create_report_post(base_dir: str,
None, None, None,
None, None, None, None, None, system_language,
None, low_bandwidth, content_license_url,
languages_understood)
languages_understood, translate)
if not post_json_object:
continue
@ -2398,6 +2402,7 @@ def send_post(signing_priv_key_pem: str, project_version: str,
shared_items_federated_domains: [],
shared_item_federation_tokens: {},
low_bandwidth: bool, content_license_url: str,
translate: {},
debug: bool = False, in_reply_to: str = None,
in_reply_to_atom_uri: str = None, subject: str = None) -> int:
"""Post to another inbox. Used by unit tests.
@ -2464,7 +2469,8 @@ def send_post(signing_priv_key_pem: str, project_version: str,
None, None, None,
None, None, None, None, None, system_language,
conversation_id, low_bandwidth,
content_license_url, languages_understood)
content_license_url, languages_understood,
translate)
# get the senders private key
private_key_pem = _get_person_key(nickname, domain, base_dir, 'private')
@ -2561,7 +2567,7 @@ def send_post_via_server(signing_priv_key_pem: str, project_version: str,
low_bandwidth: bool,
content_license_url: str,
event_date: str, event_time: str, event_end_time: str,
location: str,
location: str, translate: {},
debug: bool = False,
in_reply_to: str = None,
in_reply_to_atom_uri: str = None,
@ -2652,7 +2658,8 @@ def send_post_via_server(signing_priv_key_pem: str, project_version: str,
None, None, None, event_date, event_end_time,
None, None, None, None, None, system_language,
conversation_id, low_bandwidth,
content_license_url, languages_understood)
content_license_url, languages_understood,
translate)
auth_header = create_basic_auth_header(from_nickname, password)

View File

@ -763,6 +763,7 @@ def create_server_alice(path: str, domain: str, port: int,
test_location = None
test_is_article = False
conversation_id = None
translate = {}
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
create_public_post(path, nickname, domain, port, http_prefix,
"No wise fish would go anywhere without a porpoise",
@ -778,7 +779,7 @@ def create_server_alice(path: str, domain: str, port: int,
test_event_end_time, test_location,
test_is_article, system_language, conversation_id,
low_bandwidth, content_license_url,
languages_understood)
languages_understood, translate)
create_public_post(path, nickname, domain, port, http_prefix,
"Curiouser and curiouser!",
test_save_to_file,
@ -793,7 +794,7 @@ def create_server_alice(path: str, domain: str, port: int,
test_event_end_time, test_location,
test_is_article, system_language, conversation_id,
low_bandwidth, content_license_url,
languages_understood)
languages_understood, translate)
create_public_post(path, nickname, domain, port, http_prefix,
"In the gardens of memory, in the palace " +
"of dreams, that is where you and I shall meet",
@ -809,7 +810,7 @@ def create_server_alice(path: str, domain: str, port: int,
test_event_end_time, test_location,
test_is_article, system_language, conversation_id,
low_bandwidth, content_license_url,
languages_understood)
languages_understood, translate)
regenerate_index_for_box(path, nickname, domain, 'outbox')
global TEST_SERVER_ALICE_RUNNING
TEST_SERVER_ALICE_RUNNING = True
@ -923,6 +924,7 @@ def create_server_bob(path: str, domain: str, port: int,
test_is_article = False
conversation_id = None
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
translate = {}
create_public_post(path, nickname, domain, port, http_prefix,
"It's your life, live it your way.",
test_save_to_file,
@ -937,7 +939,7 @@ def create_server_bob(path: str, domain: str, port: int,
test_event_end_time, test_location,
test_is_article, system_language, conversation_id,
low_bandwidth, content_license_url,
languages_understood)
languages_understood, translate)
create_public_post(path, nickname, domain, port, http_prefix,
"One of the things I've realised is that " +
"I am very simple",
@ -953,7 +955,7 @@ def create_server_bob(path: str, domain: str, port: int,
test_event_end_time, test_location,
test_is_article, system_language, conversation_id,
low_bandwidth, content_license_url,
languages_understood)
languages_understood, translate)
create_public_post(path, nickname, domain, port, http_prefix,
"Quantum physics is a bit of a passion of mine",
test_save_to_file,
@ -968,7 +970,7 @@ def create_server_bob(path: str, domain: str, port: int,
test_event_end_time, test_location,
test_is_article, system_language, conversation_id,
low_bandwidth, content_license_url,
languages_understood)
languages_understood, translate)
regenerate_index_for_box(path, nickname, domain, 'outbox')
global TEST_SERVER_BOB_RUNNING
TEST_SERVER_BOB_RUNNING = True
@ -1294,6 +1296,7 @@ def test_post_message_between_servers(base_dir: str) -> None:
if os.path.isfile(os.path.join(outbox_path, name))]) == 0
low_bandwidth = False
signing_priv_key_pem = None
translate = {}
send_result = \
send_post(signing_priv_key_pem, __version__,
session_alice, alice_dir, 'alice', alice_domain, alice_port,
@ -1308,7 +1311,7 @@ def test_post_message_between_servers(base_dir: str) -> None:
languages_understood,
alice_shared_items_federated_domains,
alice_shared_item_federation_tokens, low_bandwidth,
content_license_url,
content_license_url, translate,
in_reply_to, in_reply_to_atom_uri, subject)
print('send_result: ' + str(send_result))
@ -1665,6 +1668,7 @@ def test_follow_between_servers(base_dir: str) -> None:
city = 'London, England'
low_bandwidth = False
signing_priv_key_pem = None
translate = {}
send_result = \
send_post(signing_priv_key_pem, __version__,
session_alice, alice_dir, 'alice', alice_domain, alice_port,
@ -1677,7 +1681,7 @@ def test_follow_between_servers(base_dir: str) -> None:
languages_understood,
alice_shared_items_federated_domains,
alice_shared_item_federation_tokens, low_bandwidth,
content_license_url,
content_license_url, translate,
in_reply_to, in_reply_to_atom_uri, subject)
print('send_result: ' + str(send_result))
@ -2029,6 +2033,7 @@ def test_shared_items_federation(base_dir: str) -> None:
city = 'London, England'
low_bandwidth = False
signing_priv_key_pem = None
translate = {}
send_result = \
send_post(signing_priv_key_pem, __version__,
session_alice, alice_dir, 'alice', alice_domain, alice_port,
@ -2041,7 +2046,7 @@ def test_shared_items_federation(base_dir: str) -> None:
languages_understood,
alice_shared_items_federated_domains,
alice_shared_item_federation_tokens, low_bandwidth,
content_license_url, True,
content_license_url, translate, True,
in_reply_to, in_reply_to_atom_uri, subject)
print('send_result: ' + str(send_result))
@ -2458,6 +2463,7 @@ def test_group_follow(base_dir: str) -> None:
len([name for name in os.listdir(outbox_path)
if os.path.isfile(os.path.join(outbox_path, name))])
translate = {}
send_result = \
send_post(signing_priv_key_pem, __version__,
session_alice, alice_dir, 'alice', alice_domain, alice_port,
@ -2470,7 +2476,7 @@ def test_group_follow(base_dir: str) -> None:
languages_understood,
alice_shared_items_federated_domains,
alice_shared_item_federation_tokens, low_bandwidth,
content_license_url,
content_license_url, translate,
in_reply_to, in_reply_to_atom_uri, subject)
print('send_result: ' + str(send_result))
@ -2838,6 +2844,7 @@ def _test_create_person_account(base_dir: str):
media_type = None
conversation_id = None
low_bandwidth = True
translate = {}
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
content = \
"If your \"independent organization\" is government funded...\n\n" + \
@ -2856,7 +2863,7 @@ def _test_create_person_account(base_dir: str):
test_event_end_time, test_location,
test_is_article, system_language, conversation_id,
low_bandwidth, content_license_url,
languages_understood)
languages_understood, translate)
assert test_post_json
assert test_post_json.get('object')
assert test_post_json['object']['content']
@ -2882,7 +2889,7 @@ def _test_create_person_account(base_dir: str):
test_event_end_time, test_location,
test_is_article, system_language, conversation_id,
low_bandwidth, content_license_url,
languages_understood)
languages_understood, translate)
assert test_post_json
assert test_post_json.get('object')
assert test_post_json['object']['content']
@ -3082,6 +3089,7 @@ def test_client_to_server(base_dir: str):
event_time = '11:45'
event_end_time = '12:30'
location = "Kinshasa"
translate = {}
send_result = \
send_post_via_server(signing_priv_key_pem, __version__,
alice_dir, session_alice, 'alice', password,
@ -3094,7 +3102,7 @@ def test_client_to_server(base_dir: str):
system_language, languages_understood,
low_bandwidth, content_license_url,
event_date, event_time, event_end_time, location,
True, None, None,
translate, True, None, None,
conversation_id, None)
print('send_result: ' + str(send_result))
@ -3683,6 +3691,7 @@ def _test_addemoji(base_dir: str):
domain = 'testdomain.net'
port = 3682
recipients = []
translate = {}
hashtags = {}
base_dir_original = base_dir
path = base_dir + '/.tests'
@ -3709,7 +3718,7 @@ def _test_addemoji(base_dir: str):
content_modified = \
add_html_tags(base_dir, http_prefix,
nickname, domain, content,
recipients, hashtags, True)
recipients, hashtags, translate, True)
assert ':lemon:' in content_modified
assert content_modified.startswith('<p>')
assert content_modified.endswith('</p>')
@ -4657,6 +4666,7 @@ def _test_reply_to_public_post(base_dir: str) -> None:
conversation_id = None
low_bandwidth = True
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
translate = {}
reply = \
create_public_post(base_dir, nickname, domain, port, http_prefix,
content, save_to_file,
@ -4669,7 +4679,7 @@ def _test_reply_to_public_post(base_dir: str) -> None:
test_event_end_time, test_location,
test_is_article, system_language, conversation_id,
low_bandwidth, content_license_url,
languages_understood)
languages_understood, translate)
# print(str(reply))
expected_str = \
'<p><span class=\"h-card\">' + \
@ -5588,6 +5598,7 @@ def _test_links_within_post(base_dir: str) -> None:
conversation_id = None
low_bandwidth = True
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
translate = {}
post_json_object = \
create_public_post(base_dir, nickname, domain, port, http_prefix,
@ -5601,7 +5612,7 @@ def _test_links_within_post(base_dir: str) -> None:
test_event_end_time, test_location,
test_is_article, system_language, conversation_id,
low_bandwidth, content_license_url,
languages_understood)
languages_understood, translate)
expected_str = \
'<p>This is a test post with links.<br><br>' + \
@ -5645,7 +5656,7 @@ def _test_links_within_post(base_dir: str) -> None:
test_event_end_time, test_location,
test_is_article, system_language, conversation_id,
low_bandwidth, content_license_url,
languages_understood)
languages_understood, translate)
assert post_json_object['object']['content'] == content
assert post_json_object['object']['contentMap'][system_language] == content
@ -6676,6 +6687,7 @@ def _test_can_replyto(base_dir: str) -> None:
conversation_id = None
low_bandwidth = True
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
translate = {}
post_json_object = \
create_public_post(base_dir, nickname, domain, port, http_prefix,
@ -6689,7 +6701,7 @@ def _test_can_replyto(base_dir: str) -> None:
test_event_end_time, test_location,
test_is_article, system_language, conversation_id,
low_bandwidth, content_license_url,
languages_understood)
languages_understood, translate)
# set the date on the post
curr_date_str = "2021-09-08T20:45:00Z"
post_json_object['published'] = curr_date_str

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "عرض الوسائط",
"ActivityPub Specification": "مواصفات ActivityPub",
"Dogwhistle words": "كلمات Dogwhistle",
"Content warnings will be added for the following": "ستتم إضافة تحذيرات المحتوى لما يلي"
"Content warnings will be added for the following": "ستتم إضافة تحذيرات المحتوى لما يلي",
"nowplaying": "الان العب",
"NowPlaying": "الان العب"
}

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "মিডিয়া দেখান",
"ActivityPub Specification": "ActivityPub স্পেসিফিকেশন",
"Dogwhistle words": "কুকুরের হুইসেল শব্দ",
"Content warnings will be added for the following": "নিম্নলিখিত জন্য বিষয়বস্তু সতর্কতা যোগ করা হবে"
"Content warnings will be added for the following": "নিম্নলিখিত জন্য বিষয়বস্তু সতর্কতা যোগ করা হবে",
"nowplaying": "এখন চলছে",
"NowPlaying": "এখন চলছে"
}

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "MOSTRA ELS MITJANS",
"ActivityPub Specification": "Especificació d'ActivityPub",
"Dogwhistle words": "Paraules de xiulet",
"Content warnings will be added for the following": "S'afegiran advertències de contingut per al següent"
"Content warnings will be added for the following": "S'afegiran advertències de contingut per al següent",
"nowplaying": "arajugant",
"NowPlaying": "AraJugant"
}

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "DANGOS CYFRYNGAU",
"ActivityPub Specification": "Manyleb GweithgareddPub",
"Dogwhistle words": "Geiriau chwibanogl",
"Content warnings will be added for the following": "Bydd rhybuddion cynnwys yn cael eu hychwanegu ar gyfer y canlynol"
"Content warnings will be added for the following": "Bydd rhybuddion cynnwys yn cael eu hychwanegu ar gyfer y canlynol",
"nowplaying": "nawrynchwarae",
"NowPlaying": "NawrYnChwarae"
}

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "MEDIEN ZEIGEN",
"ActivityPub Specification": "ActivityPub-Spezifikation",
"Dogwhistle words": "Hundepfeife Worte",
"Content warnings will be added for the following": "Inhaltswarnungen werden für Folgendes hinzugefügt"
"Content warnings will be added for the following": "Inhaltswarnungen werden für Folgendes hinzugefügt",
"nowplaying": "läuftgerade",
"NowPlaying": "LäuftGerade"
}

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "ΔΕΙΤΕ ΜΕΣΑ",
"ActivityPub Specification": "Προδιαγραφές ActivityPub",
"Dogwhistle words": "Σφυρίχτρα λέξεις",
"Content warnings will be added for the following": "Θα προστεθούν προειδοποιήσεις περιεχομένου για τα ακόλουθα"
"Content warnings will be added for the following": "Θα προστεθούν προειδοποιήσεις περιεχομένου για τα ακόλουθα",
"nowplaying": "τώραπαίζει",
"NowPlaying": "ΤώραΠαίζει"
}

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "SHOW MEDIA",
"ActivityPub Specification": "ActivityPub Specification",
"Dogwhistle words": "Dogwhistle words",
"Content warnings will be added for the following": "Content warnings will be added for the following"
"Content warnings will be added for the following": "Content warnings will be added for the following",
"nowplaying": "nowplaying",
"NowPlaying": "NowPlaying"
}

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "MOSTRAR MEDIOS",
"ActivityPub Specification": "Especificación de ActivityPub",
"Dogwhistle words": "Palabras de silbato para perros",
"Content warnings will be added for the following": "Se agregarán advertencias de contenido para lo siguiente"
"Content warnings will be added for the following": "Se agregarán advertencias de contenido para lo siguiente",
"nowplaying": "jugandoahora",
"NowPlaying": "JugandoAhora"
}

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "AFFICHER LES MÉDIAS",
"ActivityPub Specification": "Spécification ActivityPub",
"Dogwhistle words": "Mots de sifflet de chien",
"Content warnings will be added for the following": "Des avertissements de contenu seront ajoutés pour les éléments suivants"
"Content warnings will be added for the following": "Des avertissements de contenu seront ajoutés pour les éléments suivants",
"nowplaying": "lectureencours",
"NowPlaying": "LectureEnCours"
}

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "Taispeáin MEÁIN",
"ActivityPub Specification": "Sonraíocht ActivityPub",
"Dogwhistle words": "Focail feadóg mhadra",
"Content warnings will be added for the following": "Cuirfear rabhaidh ábhair leis maidir leis na nithe seo a leanas"
"Content warnings will be added for the following": "Cuirfear rabhaidh ábhair leis maidir leis na nithe seo a leanas",
"nowplaying": "anoisagimirt",
"NowPlaying": "AnoisAgImirt"
}

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "मीडिया दिखाएं",
"ActivityPub Specification": "गतिविधिपब विशिष्टता",
"Dogwhistle words": "कुत्ते की सीटी शब्द",
"Content warnings will be added for the following": "निम्नलिखित के लिए सामग्री चेतावनियां जोड़ दी जाएंगी"
"Content warnings will be added for the following": "निम्नलिखित के लिए सामग्री चेतावनियां जोड़ दी जाएंगी",
"nowplaying": "अब खेल रहे हैं",
"NowPlaying": "अब खेल रहे हैं"
}

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "MOSTRA MEDIA",
"ActivityPub Specification": "Specifica ActivityPub",
"Dogwhistle words": "Parole da fischietto",
"Content warnings will be added for the following": "Verranno aggiunti avvisi sui contenuti per quanto segue"
"Content warnings will be added for the following": "Verranno aggiunti avvisi sui contenuti per quanto segue",
"nowplaying": "ora giocando",
"NowPlaying": "OraGiocando"
}

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "メディアを表示",
"ActivityPub Specification": "ActivityPubの仕様",
"Dogwhistle words": "犬笛の言葉",
"Content warnings will be added for the following": "以下のコンテンツ警告が追加されます"
"Content warnings will be added for the following": "以下のコンテンツ警告が追加されます",
"nowplaying": "再生中",
"NowPlaying": "再生中"
}

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "미디어 표시",
"ActivityPub Specification": "ActivityPub 사양",
"Dogwhistle words": "개 휘파람 단어",
"Content warnings will be added for the following": "다음에 대한 콘텐츠 경고가 추가됩니다."
"Content warnings will be added for the following": "다음에 대한 콘텐츠 경고가 추가됩니다.",
"nowplaying": "지금 재생",
"NowPlaying": "지금 재생"
}

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "MEDYA NÎŞAN DE",
"ActivityPub Specification": "Specification ActivityPub",
"Dogwhistle words": "Peyvên kûçikê",
"Content warnings will be added for the following": "Hişyariyên naverokê dê ji bo jêrîn werin zêdekirin"
"Content warnings will be added for the following": "Hişyariyên naverokê dê ji bo jêrîn werin zêdekirin",
"nowplaying": "nihadilîze",
"NowPlaying": "NihaDilîze"
}

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "TOON MEDIA",
"ActivityPub Specification": "ActivityPub-specificatie",
"Dogwhistle words": "Hondenfluitwoorden",
"Content warnings will be added for the following": "Er worden inhoudswaarschuwingen toegevoegd voor het volgende:"
"Content warnings will be added for the following": "Er worden inhoudswaarschuwingen toegevoegd voor het volgende:",
"nowplaying": "nuaanhetspelen",
"NowPlaying": "NuAanHetSpelen"
}

View File

@ -563,5 +563,7 @@
"SHOW MEDIA": "SHOW MEDIA",
"ActivityPub Specification": "ActivityPub Specification",
"Dogwhistle words": "Dogwhistle words",
"Content warnings will be added for the following": "Content warnings will be added for the following"
"Content warnings will be added for the following": "Content warnings will be added for the following",
"nowplaying": "nowplaying",
"NowPlaying": "NowPlaying"
}

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "POKAŻ MEDIA",
"ActivityPub Specification": "Specyfikacja ActivityPub",
"Dogwhistle words": "Słowa gwizdka na psa",
"Content warnings will be added for the following": "Ostrzeżenia dotyczące treści zostaną dodane do następujących"
"Content warnings will be added for the following": "Ostrzeżenia dotyczące treści zostaną dodane do następujących",
"nowplaying": "terazgra",
"NowPlaying": "TerazGra"
}

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "MOSTRAR MÍDIA",
"ActivityPub Specification": "Especificação do ActivityPub",
"Dogwhistle words": "Palavras de apito",
"Content warnings will be added for the following": "Avisos de conteúdo serão adicionados para os seguintes"
"Content warnings will be added for the following": "Avisos de conteúdo serão adicionados para os seguintes",
"nowplaying": "agorajogando",
"NowPlaying": "AgoraJogando"
}

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "ПОКАЗАТЬ МЕДИА",
"ActivityPub Specification": "Спецификация ActivityPub",
"Dogwhistle words": "Собачий свисток",
"Content warnings will be added for the following": "Предупреждения о содержании будут добавлены для следующих"
"Content warnings will be added for the following": "Предупреждения о содержании будут добавлены для следующих",
"nowplaying": "сейчасиграет",
"NowPlaying": "СейчасИграет"
}

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "ONESHA VYOMBO VYA HABARI",
"ActivityPub Specification": "Vipimo vya ActivityPub",
"Dogwhistle words": "Maneno ya mbwa",
"Content warnings will be added for the following": "Maonyo ya maudhui yataongezwa kwa yafuatayo"
"Content warnings will be added for the following": "Maonyo ya maudhui yataongezwa kwa yafuatayo",
"nowplaying": "inachezasasa",
"NowPlaying": "InachezaSasa"
}

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "MEDYA GÖSTER",
"ActivityPub Specification": "ActivityPub Spesifikasyonu",
"Dogwhistle words": "İtiraf sözleri",
"Content warnings will be added for the following": "Aşağıdakiler için içerik uyarıları eklenecek"
"Content warnings will be added for the following": "Aşağıdakiler için içerik uyarıları eklenecek",
"nowplaying": "şimdioynuyor",
"NowPlaying": "ŞimdiOynuyor"
}

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "ПОКАЗАТИ ЗМІ",
"ActivityPub Specification": "Специфікація ActivityPub",
"Dogwhistle words": "Собачі слова",
"Content warnings will be added for the following": "Попередження про вміст буде додано для наступних"
"Content warnings will be added for the following": "Попередження про вміст буде додано для наступних",
"nowplaying": "заразграє",
"NowPlaying": "ЗаразГрає"
}

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "ווייַז מעדיע",
"ActivityPub Specification": "ActivityPub באַשרייַבונג",
"Dogwhistle words": "דאָגווהיסטלע ווערטער",
"Content warnings will be added for the following": "אינהאַלט וואָרנינגז וועט זיין מוסיף פֿאַר די פאלגענדע"
"Content warnings will be added for the following": "אינהאַלט וואָרנינגז וועט זיין מוסיף פֿאַר די פאלגענדע",
"nowplaying": "איצט פּלייַינג",
"NowPlaying": "איצט פּלייַינג"
}

View File

@ -567,5 +567,7 @@
"SHOW MEDIA": "展示媒体",
"ActivityPub Specification": "ActivityPub 规范",
"Dogwhistle words": "狗哨的话",
"Content warnings will be added for the following": "将为以下内容添加内容警告"
"Content warnings will be added for the following": "将为以下内容添加内容警告",
"nowplaying": "现在玩",
"NowPlaying": "现在玩"
}

View File

@ -142,7 +142,8 @@ def html_likers_of_post(base_dir: str, nickname: str,
add_emoji_to_display_name(session, base_dir,
http_prefix,
nickname, domain,
liker_name, False)
liker_name, False,
translate)
else:
liker_name = get_nickname_from_actor(liker_actor)
if not liker_name:

View File

@ -1134,7 +1134,8 @@ def _get_post_title_announce_html(base_dir: str,
announce_display_name = \
add_emoji_to_display_name(None, base_dir, http_prefix,
nickname, domain,
announce_display_name, False)
announce_display_name, False,
translate)
_log_post_timing(enable_timing_log, post_start_time, '13.3.1')
title_str += \
_announce_with_display_name_html(translate, post_json_object,
@ -1341,7 +1342,7 @@ def _get_post_title_reply_html(base_dir: str,
reply_display_name = \
add_emoji_to_display_name(None, base_dir, http_prefix,
nickname, domain,
reply_display_name, False)
reply_display_name, False, translate)
_log_post_timing(enable_timing_log, post_start_time, '13.6')
title_str += _get_reply_html(translate, in_reply_to, reply_display_name)
@ -1739,7 +1740,7 @@ def individual_post_as_html(signing_priv_key_pem: str,
display_name = \
add_emoji_to_display_name(session, base_dir, http_prefix,
nickname, domain,
display_name, False)
display_name, False, translate)
_log_post_timing(enable_timing_log, post_start_time, '7')
@ -1872,7 +1873,7 @@ def individual_post_as_html(signing_priv_key_pem: str,
display_name = \
add_emoji_to_display_name(session, base_dir, http_prefix,
nickname, domain,
display_name, False)
display_name, False, translate)
title_str += \
' <a class="imageAnchor" href="/users/' + \
nickname + '?options=' + post_actor + \
@ -2262,7 +2263,7 @@ def individual_post_as_html(signing_priv_key_pem: str,
cw_str = \
add_emoji_to_display_name(session, base_dir, http_prefix,
nickname, domain,
summary_str, False)
summary_str, False, translate)
content_str += \
'<label class="cw"><span itemprop="description">' + \
cw_str + '</span></label>\n'

View File

@ -646,12 +646,12 @@ def html_profile(signing_priv_key_pem: str,
display_name = \
add_emoji_to_display_name(session, base_dir, http_prefix,
nickname, domain,
profile_json['name'], True)
profile_json['name'], True, translate)
domain_full = get_full_domain(domain, port)
profile_description = \
add_emoji_to_display_name(session, base_dir, http_prefix,
nickname, domain,
profile_json['summary'], False)
profile_json['summary'], False, translate)
if profile_description:
profile_description = standardize_text(profile_description)
posts_button = 'button'
@ -2517,7 +2517,7 @@ def _individual_follow_as_html(signing_priv_key_pem: str,
display_name = \
add_emoji_to_display_name(None, base_dir, http_prefix,
actor_nickname, domain,
display_name, False)
display_name, False, translate)
title_str = display_name
if dormant:

View File

@ -1006,7 +1006,8 @@ def load_individual_post_as_html_from_cache(base_dir: str,
def add_emoji_to_display_name(session, base_dir: str, http_prefix: str,
nickname: str, domain: str,
display_name: str, in_profile_name: bool) -> str:
display_name: str, in_profile_name: bool,
translate: {}) -> str:
"""Adds emoji icons to display names or CW on individual posts
"""
if ':' not in display_name:
@ -1017,7 +1018,8 @@ def add_emoji_to_display_name(session, base_dir: str, http_prefix: str,
# print('TAG: display_name before tags: ' + display_name)
display_name = \
add_html_tags(base_dir, http_prefix,
nickname, domain, display_name, [], emoji_tags)
nickname, domain, display_name, [],
emoji_tags, translate)
display_name = display_name.replace('<p>', '').replace('</p>', '')
# print('TAG: display_name after tags: ' + display_name)
# convert the emoji dictionary to a list