103def get_infobox(alt_forms, result_url, definitions):
104 infobox_content = []
105
106 infobox_title = alt_forms[0]
107 if len(alt_forms) > 1:
108 infobox_content.append(f'<p><i>Other forms:</i> {", ".join(alt_forms[1:])}</p>')
109
110
111 infobox_content.append(
112 '''
113 <small><a href="https://www.edrdg.org/wiki/index.php/JMdict-EDICT_Dictionary_Project">JMdict</a>
114 and <a href="https://www.edrdg.org/enamdict/enamdict_doc.html">JMnedict</a>
115 by <a href="https://www.edrdg.org/edrdg/licence.html">EDRDG</a>, CC BY-SA 3.0.</small>
116 <ul>
117 '''
118 )
119 for pos, engdef, extra in definitions:
120 if pos == 'Wikipedia definition':
121 infobox_content.append('</ul><small>Wikipedia, CC BY-SA 3.0.</small><ul>')
122 pos = f'<i>{pos}</i>: ' if pos else ''
123 extra = f' ({extra})' if extra else ''
124 infobox_content.append(f'<li>{pos}{engdef}{extra}</li>')
125 infobox_content.append('</ul>')
126
127
128 return {
129 'infobox': infobox_title,
130 'content': ''.join(infobox_content),
131 'urls': [
132 {
133 'title': 'Jisho.org',
134 'url': result_url,
135 }
136 ],
137 }