code: def string_to_locale(value, strict=True):
      
      try:
          return None if is_undefined(value) else Locale.from_string(value, strict=strict)
      except Locale.MalformedLocaleException, exception:
          if strict:
              raise exception
docs: Return an instance ``Locale`` corresponding to the string
      representation of a locale.
  
      @param value: a string representation of a locale, i.e., a ISO 639-3
          alpha-3 code (or alpha-2 code), optionally followed by a dash
          character ``-`` and a ISO 3166-1 alpha-2 code.
  
      @param strict: indicate whether the string representation of a locale
          has to be strictly compliant with RFC 4646, or whether a Java-
          style locale (character ``_`` instead of ``-``) is accepted.
  
      @return: an instance ``Locale``.