+ w = e[lang].split(',')
+ id = word2id(w[0])
+ while id in ids:
+ id = id + 'x'
+ ids[id] = True
+
+ # First handle redirections with not extra info
+ if -1 != e[lang].find('>') and ldesc not in e:
+ p = e[lang].split(' > ')
+ if p[0] in redirects: # Skip if already added
+ continue
+ if -1 == p[1].find(','):
+ if '-' == p[1][-1]:
+ print("warning: Skipping dangling reference %s -> %s" %
+ (p[0], p[1]))
+ else:
+ seeentry = E.glossentry()
+ seeentry.append(E.glossterm(p[0]))
+ id = word2id(p[1])
+ seeentry.append(E.glosssee(otherterm=id))
+ glossary.append(seeentry)
+ redirects[p[0]] = id
+ else:
+ print("warning: skipping split refererence %s -> %s" %
+ (p[0], p[1]))
+ if False: # Not allowed in docbook
+ seeentry = E.glossentry()
+ seeentry.append(E.glossterm(p[0]))
+ for s in p[1].split(','):
+ s = s.strip().lstrip()
+ seeentry.append(E.glosssee(otherterm=word2id(s)))
+ glossary.append(seeentry)
+ continue
+
+ # Add See also entries pointing to main entry
+ if 1 < len(w):
+ for t in w[1:]:
+ t = t.strip().lstrip()
+ if t not in redirects:
+ #print("info: Adding see also entry for %s" % t)
+ seeentry = E.glossentry()
+ seeentry.append(E.glossterm(t))
+ seeentry.append(E.glosssee(otherterm=id))
+ glossary.append(seeentry)
+ redirects[t] = id
+ elif ldesc not in e:
+ print("warning: term %s missing primary language %s description" % (e[lang], lang))
+ entry = E.glossentry(id=id)
+ if list_topic and 'topic' in e:
+ entry.append(E.glossterm('%s [%s]' % (e[lang], e['topic'])))
+ else:
+ entry.append(E.glossterm(e[lang]))
+ indexit(entry, e[lang])
+ lstr = ""
+ for l in langcodes:
+ if l != lang and l in e:
+ lstr += "%s (%s) " % (e[l], l)
+ # Add foreign words to index, split on comma
+ indexit(entry, e[l], l)
+ if "" != lstr:
+ entry.append(E.glossdef(E.para(lstr)))
+ else:
+ # only single word witout translations, skip it
+ continue
+ for desccode in desccodes:
+ codestr = 'desc-%s' % desccode
+ if codestr in e:
+ entry.append(E.glossdef(E.para("(%s): %s" % (desccode,
+ e[codestr]))))
+ glossary.append(entry)
+
+ def glosstermlocale(x):
+ # Look up glossterm (FIXME figure out more robust way)
+ t = x.getchildren()[0].text
+ if t:
+ return locale.strxfrm(t)