code: def wrap_text(translations, linewrap=0):
      
      # pylint: disable=too-many-locals
  
      def wrap(text, width=linewrap, findent=0, sindent=0, bold=False):
          if width == 0:
              text = " " * findent + text
          else:
              text = textwrap.fill(
                  text,
                  width=width,
                  initial_indent=" " * findent,
                  subsequent_indent=" " * sindent,
              )
          # don't use bold when stdout is pipe or redirect
          if bold and sys.stdout.isatty():
              text = "\033[0;1m" + text + "\033[0m"
          return text
  
      indent = 5
      result = []
      for i1, trans in enumerate(translations):
          if i1 > 0:
              result.append("\n")
          for w in trans.word:
              result.append(wrap(w, bold=True))
          for i2, t in enumerate(trans.parts_of_speech):
              if i2 > 0:
                  result.append("")
              if t.part:
                  result.append("[{part}]".format(part=t.part))
              for i3, m in enumerate(t.meanings, 1):
                  if i3 > 1:
                      result.append("")
                  meaning = "{index:>3}. {meanings}".format(
                      index=i3, meanings=", ".join(m.meaning)
                  )
                  result.append(wrap(meaning, sindent=indent, bold=True))
                  eindent = indent + 1
                  for e in m.examples:
                      result.append("")
                      result.append(wrap(e[0], findent=eindent, sindent=eindent))
                      if len(e) == 2 and e[1]:
                          result.append(wrap(e[1], findent=eindent, sindent=eindent + 1))
      return "\n".join(result)
docs: Pretty print translations.
  
      If linewrap is set to 0 disble line wrapping.
  
      Parameters
      ----------
      translations : list
          List of word translations.
      linewrap : int
          Maximum line length before wrapping.