code: def ordinal(value):
      
      try:
          value = int(value)
      except (TypeError, ValueError):
          return value
      t = (P_('0', 'th'),
           P_('1', 'st'),
           P_('2', 'nd'),
           P_('3', 'rd'),
           P_('4', 'th'),
           P_('5', 'th'),
           P_('6', 'th'),
           P_('7', 'th'),
           P_('8', 'th'),
           P_('9', 'th'))
      if value % 100 in (11, 12, 13):  # special case
          return "%d%s" % (value, t[0])
      return '%d%s' % (value, t[value % 10])
docs: Converts an integer to its ordinal as a string. 1 is '1st', 2 is '2nd',
      3 is '3rd', etc. Works for any integer or anything int() will turn into an
      integer.  Anything other value will have nothing done to it.