code: def get_locales(prefix=None, normalize=True,
                  locale_getter=_default_locale_getter):
      
      try:
          raw_locales = locale_getter()
      except Exception:
          return None
  
      try:
          # raw_locales is "\n" separated list of locales
          # it may contain non-decodable parts, so split
          # extract what we can and then rejoin.
          raw_locales = raw_locales.split(b'\n')
          out_locales = []
          for x in raw_locales:
              out_locales.append(str(
                  x, encoding=options.display.encoding))
  
      except TypeError:
          pass
  
      if prefix is None:
          return _valid_locales(out_locales, normalize)
  
      pattern = re.compile('{prefix}.*'.format(prefix=prefix))
      found = pattern.findall('\n'.join(out_locales))
      return _valid_locales(found, normalize)
docs: Get all the locales that are available on the system.
  
      Parameters
      ----------
      prefix : str
          If not ``None`` then return only those locales with the prefix
          provided. For example to get all English language locales (those that
          start with ``"en"``), pass ``prefix="en"``.
      normalize : bool
          Call ``locale.normalize`` on the resulting list of available locales.
          If ``True``, only locales that can be set without throwing an
          ``Exception`` are returned.
      locale_getter : callable
          The function to use to retrieve the current locales. This should return
          a string with each locale separated by a newline character.
  
      Returns
      -------
      locales : list of strings
          A list of locale strings that can be set with ``locale.setlocale()``.
          For example::
  
              locale.setlocale(locale.LC_ALL, locale_string)
  
      On error will return None (no locale available, e.g. Windows)