def get_locales(prefix=None, normalize=True,<EOL>locale_getter=_default_locale_getter):
try:<EOL><INDENT>raw_locales = locale_getter()<EOL><DEDENT>except Exception:<EOL><INDENT>return None<EOL><DEDENT>try:<EOL><INDENT>raw_locales = raw_locales.split(b'<STR_LIT:\n>')<EOL>out_locales = []<EOL>for x in raw_locales:<EOL><INDENT>out_locales.append(str(<EOL>x, encoding=options.display.encoding))<EOL><DEDENT><DEDENT>except TypeError:<EOL><INDENT>pass<EOL><DEDENT>if prefix is None:<EOL><INDENT>return _valid_locales(out_locales, normalize)<EOL><DEDENT>pattern = re.compile('<STR_LIT>'.format(prefix=prefix))<EOL>found = pattern.findall('<STR_LIT:\n>'.join(out_locales))<EOL>return _valid_locales(found, normalize)<EOL>
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)