def _valid_locales(locales, normalize):
if normalize:<EOL><INDENT>normalizer = lambda x: locale.normalize(x.strip())<EOL><DEDENT>else:<EOL><INDENT>normalizer = lambda x: x.strip()<EOL><DEDENT>return list(filter(can_set_locale, map(normalizer, locales)))<EOL>
Return a list of normalized locales that do not throw an ``Exception``
when set.

Parameters
----------
locales : str
    A string where each locale is separated by a newline.
normalize : bool
    Whether to call ``locale.normalize`` on each locale.

Returns
-------
valid_locales : list
    A list of valid locales.