old_contents: import collections
  
  
  def localize(value, lang):
      """
      Localize the given value.
  
      This function is intended to be used within UCR to localize user supplied
      translations.
  
      :param value: A dict-like object or string
      :param lang: A language code.
      """
      if isinstance(value, basestring) or value is None:
          return value
      if isinstance(value, collections.Mapping) and len(value):
          return (
              value.get(lang, None) or
              value.get("en", None) or
              value[sorted(value.keys())[0]]
          )
      return value
  
new_contents: import collections
  
  
  def localize(value, lang):
      """
      Localize the given value.
  
      This function is intended to be used within UCR to localize user supplied
      translations.
  
      :param value: A dict-like object or string
      :param lang: A language code.
      """
      if isinstance(value, collections.Mapping) and len(value):
          return (
              value.get(lang, None) or
              value.get("en", None) or
              value[sorted(value.keys())[0]]
          )
      return value
  
subject: Remove unneeded case in util.localize()