29def response(resp):
30 results = []
31
32 result = loads(resp.text)
33 info = result["info"]
34 from_to_prefix = "%s-%s " % (resp.search_params['from_lang'][1], resp.search_params['to_lang'][1])
35
36 if "typo" in info:
37 results.append({"suggestion": from_to_prefix + info["typo"]})
38
39 if 'definitions' in info:
40 for definition in info['definitions']:
41 if 'list' in definition:
42 for item in definition['list']:
43 if 'synonyms' in item:
44 for synonym in item['synonyms']:
45 results.append({"suggestion": from_to_prefix + synonym})
46
47 infobox = ""
48
49 for translation in info["extraTranslations"]:
50 for word in translation["list"]:
51 infobox += f"<dl><dt>{word['word']}</dt>"
52
53 for meaning in word["meanings"]:
54 infobox += f"<dd>{meaning}</dd>"
55
56 infobox += "</dl>"
57
58 results.append(
59 {
60 'infobox': result["translation"],
61 'content': infobox,
62 }
63 )
64
65 return results