# locale - pydoc - phpman

> **TLDR:** Get locale-specific information.
>
- List all global environment variables describing the user's locale:
  `locale`
- List all available locales:
  `locale {{-a|--all-locales}}`
- Display all available locales and the associated metadata:
  `locale {{-a|--all-locales}} {{-v|--verbose}}`
- Display the current date format:
  `locale date_fmt`

*Source: tldr-pages*

---

Help on module locale:

## NAME
    locale - Locale support module.

## MODULE REFERENCE
    <https://docs.python.org/3.10/library/locale.html>

    The following documentation is automatically generated from the Python
    source files.  It may be incomplete, incorrect or include features that
    are considered implementation detail and may vary between Python
    implementations.  When in doubt, consult the module reference at the
    location listed above.

## DESCRIPTION
    The module provides low-level access to the C lib's locale APIs and adds high
    level number formatting APIs as well as a locale aliasing engine to complement
    these.

    The aliasing engine includes support for many commonly used locale names and
    maps them to values suitable for passing to the C lib's setlocale() function. It
    also includes default encodings for all supported locale names.

## CLASSES
    builtins.Exception(builtins.BaseException)
        Error

### class Error
     |  Method resolution order:
     |      Error
     |      builtins.Exception
     |      builtins.BaseException
     |      builtins.object
     |
     |  Data descriptors defined here:
     |
     |  __weakref__
     |      list of weak references to the object (if defined)
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from builtins.Exception:
     |
     |  __init__(self, /, *args, **kwargs)
     |      Initialize self.  See help(type(self)) for accurate signature.
     |
     |  ----------------------------------------------------------------------
     |  Static methods inherited from builtins.Exception:
     |
     |  __new__(*args, **kwargs) from builtins.type
     |      Create and return a new object.  See help(type) for accurate signature.
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from builtins.BaseException:
     |
     |  __delattr__(self, name, /)
     |      Implement delattr(self, name).
     |
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |
     |  __reduce__(...)
     |      Helper for pickle.
     |
     |  __repr__(self, /)
     |      Return repr(self).
     |
     |  __setattr__(self, name, value, /)
     |      Implement setattr(self, name, value).
     |
     |  __setstate__(...)
     |
     |  __str__(self, /)
     |      Return str(self).
     |
     |  with_traceback(...)
     |      Exception.with_traceback(tb) --
     |      set self.__traceback__ to tb and return self.
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from builtins.BaseException:
     |
     |  __cause__
     |      exception cause
     |
     |  __context__
     |      exception context
     |
     |  __dict__
     |
     |  __suppress_context__
     |
     |  __traceback__
     |
     |  args

## FUNCTIONS
### atof
        Parses a string as a float according to the locale settings.

### atoi
        Converts a string to an integer according to the locale settings.

### currency
        Formats val according to the currency settings
        in the current locale.

### format
        Deprecated, use format_string instead.

### format_string
        Formats a string in the same way that the % formatting would use,
        but takes the current locale into account.

        Grouping is applied if the third parameter is true.
        Conversion uses monetary thousands separator and grouping strings if
        forth parameter monetary is true.

### getdefaultlocale
        Tries to determine the default locale settings and returns
        them as tuple (language code, encoding).

        According to POSIX, a program which has not called
        setlocale(LC_ALL, "") runs using the portable 'C' locale.
        Calling setlocale(LC_ALL, "") lets it use the default locale as
        defined by the LANG variable. Since we don't want to interfere
        with the current locale setting we thus emulate the behavior
        in the way described above.

        To maintain compatibility with other platforms, not only the
        LANG variable is tested, but a list of variables given as
        envvars parameter. The first found to be defined will be
        used. envvars defaults to the search path used in GNU gettext;
        it must always contain the variable name 'LANG'.

        Except for the code 'C', the language code corresponds to RFC
        1766.  code and encoding can be None in case the values cannot
        be determined.

### getlocale
        Returns the current setting for the given locale category as
        tuple (language code, encoding).

        category may be one of the LC_* value except LC_ALL. It
        defaults to LC_CTYPE.

        Except for the code 'C', the language code corresponds to RFC
        1766.  code and encoding can be None in case the values cannot
        be determined.

### getpreferredencoding
        Return the charset that the user is likely using,
        according to the system configuration.

### localeconv
        Returns numeric and monetary locale-specific parameters.

### normalize
        Returns a normalized locale code for the given locale
        name.

        The returned locale code is formatted for use with
        setlocale().

        If normalization fails, the original name is returned
        unchanged.

        If the given encoding is not known, the function defaults to
        the default encoding for the locale code just like setlocale()
        does.

### resetlocale
        Sets the locale for category to the default setting.

        The default setting is determined by calling
        getdefaultlocale(). category defaults to LC_ALL.

### setlocale
        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.

### str
        Convert float to string, taking the locale into account.

### strcoll
        Compares two strings according to the locale.

### strxfrm
        Return a string that can be used as a key for locale-aware comparisons.

## DATA
    CHAR_MAX = 127
    LC_ALL = 6
    LC_COLLATE = 3
    LC_CTYPE = 0
    LC_MESSAGES = 5
    LC_MONETARY = 4
    LC_NUMERIC = 1
    LC_TIME = 2
    __all__ = ['getlocale', 'getdefaultlocale', 'getpreferredencoding', 'E...

## FILE
    /usr/lib/python3.10/locale.py


