babel.localedata ~~~~~~~~~~~~~~~~ Low-level locale data access. :note: The `Locale` class, which uses this module under the hood, provides a more convenient interface for accessing the locale data. :copyright: (c) 2013-2023 by the Babel Team. :license: BSD, see LICENSE for more details.
Class |
|
Representation of an alias in the locale data. |
Class |
|
Dictionary wrapper that automatically resolves aliases to the actual values. |
Function | exists |
Check whether locale data is available for the given locale. |
Function | load |
Load the locale data for the given locale. |
Function | locale |
Return a list of all locale identifiers for which locale data is available. |
Function | merge |
Merge the data from `dict2` into the `dict1` dictionary, making copies of nested dictionaries. |
Function | normalize |
Normalize a locale ID by stripping spaces and apply proper casing. |
Function | resolve |
Resolve a locale identifier to a `.dat` path on disk. |
Variable | _cache |
Undocumented |
Variable | _cache |
Undocumented |
Variable | _dirname |
Undocumented |
Variable | _windows |
Undocumented |
Check whether locale data is available for the given locale. Returns `True` if it exists, `False` otherwise. :param name: the locale identifier string
Load the locale data for the given locale. The locale data is a dictionary that contains much of the data defined by the Common Locale Data Repository (CLDR). This data is stored as a collection of pickle files inside the ``babel`` package. >>> d = load('en_US') >>> d['languages']['sv'] u'Swedish' Note that the results are cached, and subsequent requests for the same locale return the same dictionary: >>> d1 = load('en_US') >>> d2 = load('en_US') >>> d1 is d2 True :param name: the locale identifier string (or "root") :param merge_inherited: whether the inherited data should be merged into the data of the requested locale :raise `IOError`: if no locale data file is found for the given locale identifier, or one of the locales it inherits from
Return a list of all locale identifiers for which locale data is available. This data is cached after the first invocation. You can clear the cache by calling `locale_identifiers.cache_clear()`. .. versionadded:: 0.8.1 :return: a list of locale identifiers (strings)
Merge the data from `dict2` into the `dict1` dictionary, making copies of nested dictionaries. >>> d = {1: 'foo', 3: 'baz'} >>> merge(d, {1: 'Foo', 2: 'Bar'}) >>> sorted(d.items()) [(1, 'Foo'), (2, 'Bar'), (3, 'baz')] :param dict1: the dictionary to merge into :param dict2: the dictionary containing the data that should be merged
Normalize a locale ID by stripping spaces and apply proper casing. Returns the normalized locale ID string or `None` if the ID is not recognized.