PyDocs

Nav

Internationalization

setlocale

locale

function (source)
  • setlocale(category, locale=None)
Set the locale for the given category.  The locale can be
a string, an iterable of two strings (language code and encoding),
or None.

Iterables are converted to strings using the locale aliasing
engine.  Locale strings are passed directly to the C lib.

category may be given as one of the LC_* values.
Changed in 3.15
  • 3.15: Support language codes with @-modifiers.
1 Example
>>> import locale
>>> loc = locale.setlocale(locale.LC_ALL)  # get current locale
# use German locale; name and availability varies with platform
>>> locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8')
>>> locale.strcoll('f\xe4n', 'foo')  # compare a string containing an umlaut
>>> locale.setlocale(locale.LC_ALL, '')   # use user's preferred locale
>>> locale.setlocale(locale.LC_ALL, 'C')  # use default (C) locale
>>> locale.setlocale(locale.LC_ALL, loc)  # restore saved locale
from the Python docs
See Also
No see-alsos for locale/setlocale
0 Notes
No notes for setlocale