35def response(resp):
36 translation = resp.json()
37
38 infobox = ""
39
40 if translation['target_transliteration'] and not re.match(
41 re_transliteration_unsupported, translation['target_transliteration']
42 ):
43 infobox = f"<b>{translation['target_transliteration']}</b>"
44
45 if translation['word_choices']:
46 for word in translation['word_choices']:
47 infobox += f"<dl><dt>{word['word']}: {word['definition']}</dt>"
48
49 if word['examples_target']:
50 for example in word['examples_target']:
51 infobox += f"<dd>{re.sub(r'<|>', '', example)}</dd>"
52 infobox += f"<dd>{re.sub(r'<|>', '', example)}</dd>"
53
54 infobox += "</dl>"
55
56 if translation['source_synonyms']:
57 infobox += f"<dl><dt>{gettext('Synonyms')}: {', '.join(translation['source_synonyms'])}</dt></dl>"
58
59 result = {
60 'infobox': translation['translated-text'],
61 'content': infobox,
62 }
63
64 return [result]