Qucs-S S-parameter Viewer & RF Synthesis Tools
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Member Functions | Properties | List of all members
babel.core.Locale Class Reference

Public Member Functions

None __init__ (self, str language, str|None territory=None, str|None script=None, str|None variant=None, str|None modifier=None)
 
Locale default (cls, str|None category=None, Mapping[str, str] aliases=LOCALE_ALIASES)
 
Locale|None negotiate (cls, Iterable[str] preferred, Iterable[str] available, str sep='_', Mapping[str, str] aliases=LOCALE_ALIASES)
 
Locale parse (cls, Locale|str|None identifier, str sep='_', bool resolve_likely_subtags=True)
 
bool __eq__ (self, object other)
 
bool __ne__ (self, object other)
 
int __hash__ (self)
 
str __repr__ (self)
 
str __str__ (self)
 
str|None get_display_name (self, Locale|str|None locale=None)
 
str|None get_language_name (self, Locale|str|None locale=None)
 
str|None get_territory_name (self, Locale|str|None locale=None)
 
str|None get_script_name (self, Locale|str|None locale=None)
 
str|None english_name (self)
 
localedata.LocaleDataDict languages (self)
 
localedata.LocaleDataDict scripts (self)
 
localedata.LocaleDataDict territories (self)
 
localedata.LocaleDataDict variants (self)
 
localedata.LocaleDataDict currencies (self)
 
localedata.LocaleDataDict currency_symbols (self)
 
localedata.LocaleDataDict number_symbols (self)
 
localedata.LocaleDataDict other_numbering_systems (self)
 
str default_numbering_system (self)
 
localedata.LocaleDataDict decimal_formats (self)
 
localedata.LocaleDataDict compact_decimal_formats (self)
 
localedata.LocaleDataDict currency_formats (self)
 
localedata.LocaleDataDict compact_currency_formats (self)
 
localedata.LocaleDataDict percent_formats (self)
 
localedata.LocaleDataDict scientific_formats (self)
 
localedata.LocaleDataDict periods (self)
 
localedata.LocaleDataDict day_periods (self)
 
localedata.LocaleDataDict day_period_rules (self)
 
localedata.LocaleDataDict days (self)
 
localedata.LocaleDataDict months (self)
 
localedata.LocaleDataDict quarters (self)
 
localedata.LocaleDataDict eras (self)
 
localedata.LocaleDataDict time_zones (self)
 
localedata.LocaleDataDict meta_zones (self)
 
localedata.LocaleDataDict zone_formats (self)
 
int first_week_day (self)
 
int weekend_start (self)
 
int weekend_end (self)
 
int min_week_days (self)
 
localedata.LocaleDataDict date_formats (self)
 
localedata.LocaleDataDict time_formats (self)
 
localedata.LocaleDataDict datetime_formats (self)
 
localedata.LocaleDataDict datetime_skeletons (self)
 
localedata.LocaleDataDict interval_formats (self)
 
PluralRule plural_form (self)
 
localedata.LocaleDataDict list_patterns (self)
 
PluralRule ordinal_form (self)
 
localedata.LocaleDataDict measurement_systems (self)
 
str character_order (self)
 
str text_direction (self)
 
localedata.LocaleDataDict unit_display_names (self)
 

Public Attributes

 language
 
 territory
 
 script
 
 variant
 
 modifier
 

Protected Member Functions

localedata.LocaleDataDict _data (self)
 

Properties

 display_name = property(get_display_name, doc=)
 
 language_name = property(get_language_name, doc=)
 
 territory_name = property(get_territory_name, doc=)
 
 script_name = property(get_script_name, doc=)
 

Detailed Description

Representation of a specific locale.

>>> locale = Locale('en', 'US')
>>> repr(locale)
"Locale('en', territory='US')"
>>> locale.display_name
u'English (United States)'

A `Locale` object can also be instantiated from a raw locale string:

>>> locale = Locale.parse('en-US', sep='-')
>>> repr(locale)
"Locale('en', territory='US')"

`Locale` objects provide access to a collection of locale data, such as
territory and language names, number and date format patterns, and more:

>>> locale.number_symbols['latn']['decimal']
u'.'

If a locale is requested for which no locale data is available, an
`UnknownLocaleError` is raised:

>>> Locale.parse('en_XX')
Traceback (most recent call last):
    ...
UnknownLocaleError: unknown locale 'en_XX'

For more information see :rfc:`3066`.

Constructor & Destructor Documentation

◆ __init__()

None babel.core.Locale.__init__ (   self,
str  language,
str | None   territory = None,
str | None   script = None,
str | None   variant = None,
str | None   modifier = None 
)
Initialize the locale object from the given identifier components.

>>> locale = Locale('en', 'US')
>>> locale.language
'en'
>>> locale.territory
'US'

:param language: the language code
:param territory: the territory (country or region) code
:param script: the script code
:param variant: the variant code
:param modifier: a modifier (following the '@' symbol, sometimes called '@variant')
:raise `UnknownLocaleError`: if no locale data is available for the
                             requested locale

Member Function Documentation

◆ character_order()

str babel.core.Locale.character_order (   self)
The text direction for the language.

>>> Locale('de', 'DE').character_order
'left-to-right'
>>> Locale('ar', 'SA').character_order
'right-to-left'

◆ compact_currency_formats()

localedata.LocaleDataDict babel.core.Locale.compact_currency_formats (   self)
Locale patterns for compact currency number formatting.

.. note:: The format of the value returned may change between
          Babel versions.

>>> Locale('en', 'US').compact_currency_formats["short"]["one"]["1000"]
<NumberPattern u'¤0K'>

◆ compact_decimal_formats()

localedata.LocaleDataDict babel.core.Locale.compact_decimal_formats (   self)
Locale patterns for compact decimal number formatting.

.. note:: The format of the value returned may change between
          Babel versions.

>>> Locale('en', 'US').compact_decimal_formats["short"]["one"]["1000"]
<NumberPattern u'0K'>

◆ currencies()

localedata.LocaleDataDict babel.core.Locale.currencies (   self)
Mapping of currency codes to translated currency names.  This
only returns the generic form of the currency name, not the count
specific one.  If an actual number is requested use the
:func:`babel.numbers.get_currency_name` function.

>>> Locale('en').currencies['COP']
u'Colombian Peso'
>>> Locale('de', 'DE').currencies['COP']
u'Kolumbianischer Peso'

◆ currency_formats()

localedata.LocaleDataDict babel.core.Locale.currency_formats (   self)
Locale patterns for currency number formatting.

.. note:: The format of the value returned may change between
          Babel versions.

>>> Locale('en', 'US').currency_formats['standard']
<NumberPattern u'\\xa4#,##0.00'>
>>> Locale('en', 'US').currency_formats['accounting']
<NumberPattern u'\\xa4#,##0.00;(\\xa4#,##0.00)'>

◆ currency_symbols()

localedata.LocaleDataDict babel.core.Locale.currency_symbols (   self)
Mapping of currency codes to symbols.

>>> Locale('en', 'US').currency_symbols['USD']
u'$'
>>> Locale('es', 'CO').currency_symbols['USD']
u'US$'

◆ date_formats()

localedata.LocaleDataDict babel.core.Locale.date_formats (   self)
Locale patterns for date formatting.

.. note:: The format of the value returned may change between
          Babel versions.

>>> Locale('en', 'US').date_formats['short']
<DateTimePattern u'M/d/yy'>
>>> Locale('fr', 'FR').date_formats['long']
<DateTimePattern u'd MMMM y'>

◆ datetime_formats()

localedata.LocaleDataDict babel.core.Locale.datetime_formats (   self)
Locale patterns for datetime formatting.

.. note:: The format of the value returned may change between
          Babel versions.

>>> Locale('en').datetime_formats['full']
u'{1}, {0}'
>>> Locale('th').datetime_formats['medium']
u'{1} {0}'

◆ datetime_skeletons()

localedata.LocaleDataDict babel.core.Locale.datetime_skeletons (   self)
Locale patterns for formatting parts of a datetime.

>>> Locale('en').datetime_skeletons['MEd']
<DateTimePattern u'E, M/d'>
>>> Locale('fr').datetime_skeletons['MEd']
<DateTimePattern u'E dd/MM'>
>>> Locale('fr').datetime_skeletons['H']
<DateTimePattern u"HH 'h'">

◆ day_period_rules()

localedata.LocaleDataDict babel.core.Locale.day_period_rules (   self)
Day period rules for the locale.  Used by `get_period_id`.

◆ day_periods()

localedata.LocaleDataDict babel.core.Locale.day_periods (   self)
Locale display names for various day periods (not necessarily only AM/PM).

These are not meant to be used without the relevant `day_period_rules`.

◆ days()

localedata.LocaleDataDict babel.core.Locale.days (   self)
Locale display names for weekdays.

>>> Locale('de', 'DE').days['format']['wide'][3]
u'Donnerstag'

◆ decimal_formats()

localedata.LocaleDataDict babel.core.Locale.decimal_formats (   self)
Locale patterns for decimal number formatting.

.. note:: The format of the value returned may change between
          Babel versions.

>>> Locale('en', 'US').decimal_formats[None]
<NumberPattern u'#,##0.###'>

◆ default()

Locale babel.core.Locale.default (   cls,
str | None   category = None,
Mapping[str, str]   aliases = LOCALE_ALIASES 
)
Return the system default locale for the specified category.

>>> for name in ['LANGUAGE', 'LC_ALL', 'LC_CTYPE', 'LC_MESSAGES']:
...     os.environ[name] = ''
>>> os.environ['LANG'] = 'fr_FR.UTF-8'
>>> Locale.default('LC_MESSAGES')
Locale('fr', territory='FR')

The following fallbacks to the variable are always considered:

- ``LANGUAGE``
- ``LC_ALL``
- ``LC_CTYPE``
- ``LANG``

:param category: one of the ``LC_XXX`` environment variable names
:param aliases: a dictionary of aliases for locale identifiers

◆ default_numbering_system()

str babel.core.Locale.default_numbering_system (   self)
The default numbering system used by the locale.
>>> Locale('el', 'GR').default_numbering_system
u'latn'

◆ english_name()

str | None babel.core.Locale.english_name (   self)
The english display name of the locale.

>>> Locale('de').english_name
u'German'
>>> Locale('de', 'DE').english_name
u'German (Germany)'

:type: `unicode`

◆ eras()

localedata.LocaleDataDict babel.core.Locale.eras (   self)
Locale display names for eras.

.. note:: The format of the value returned may change between
          Babel versions.

>>> Locale('en', 'US').eras['wide'][1]
u'Anno Domini'
>>> Locale('en', 'US').eras['abbreviated'][0]
u'BC'

◆ first_week_day()

int babel.core.Locale.first_week_day (   self)
The first day of a week, with 0 being Monday.

>>> Locale('de', 'DE').first_week_day
0
>>> Locale('en', 'US').first_week_day
6

◆ get_display_name()

str | None babel.core.Locale.get_display_name (   self,
Locale | str | None   locale = None 
)
Return the display name of the locale using the given locale.

The display name will include the language, territory, script, and
variant, if those are specified.

>>> Locale('zh', 'CN', script='Hans').get_display_name('en')
u'Chinese (Simplified, China)'

Modifiers are currently passed through verbatim:

>>> Locale('it', 'IT', modifier='euro').get_display_name('en')
u'Italian (Italy, euro)'

:param locale: the locale to use

◆ get_language_name()

str | None babel.core.Locale.get_language_name (   self,
Locale | str | None   locale = None 
)
Return the language of this locale in the given locale.

>>> Locale('zh', 'CN', script='Hans').get_language_name('de')
u'Chinesisch'

.. versionadded:: 1.0

:param locale: the locale to use

◆ get_script_name()

str | None babel.core.Locale.get_script_name (   self,
Locale | str | None   locale = None 
)
Return the script name in the given locale.

◆ get_territory_name()

str | None babel.core.Locale.get_territory_name (   self,
Locale | str | None   locale = None 
)
Return the territory name in the given locale.

◆ interval_formats()

localedata.LocaleDataDict babel.core.Locale.interval_formats (   self)
Locale patterns for interval formatting.

.. note:: The format of the value returned may change between
          Babel versions.

How to format date intervals in Finnish when the day is the
smallest changing component:

>>> Locale('fi_FI').interval_formats['MEd']['d']
[u'E d.\u2009\u2013\u2009', u'E d.M.']

.. seealso::

   The primary API to use this data is :py:func:`babel.dates.format_interval`.


:rtype: dict[str, dict[str, list[str]]]

◆ languages()

localedata.LocaleDataDict babel.core.Locale.languages (   self)
Mapping of language codes to translated language names.

>>> Locale('de', 'DE').languages['ja']
u'Japanisch'

See `ISO 639 <https://www.loc.gov/standards/iso639-2/>`_ for
more information.

◆ list_patterns()

localedata.LocaleDataDict babel.core.Locale.list_patterns (   self)
Patterns for generating lists

.. note:: The format of the value returned may change between
          Babel versions.

>>> Locale('en').list_patterns['standard']['start']
u'{0}, {1}'
>>> Locale('en').list_patterns['standard']['end']
u'{0}, and {1}'
>>> Locale('en_GB').list_patterns['standard']['end']
u'{0} and {1}'

◆ measurement_systems()

localedata.LocaleDataDict babel.core.Locale.measurement_systems (   self)
Localized names for various measurement systems.

>>> Locale('fr', 'FR').measurement_systems['US']
u'am\\xe9ricain'
>>> Locale('en', 'US').measurement_systems['US']
u'US'

◆ meta_zones()

localedata.LocaleDataDict babel.core.Locale.meta_zones (   self)
Locale display names for meta time zones.

Meta time zones are basically groups of different Olson time zones that
have the same GMT offset and daylight savings time.

.. note:: The format of the value returned may change between
          Babel versions.

>>> Locale('en', 'US').meta_zones['Europe_Central']['long']['daylight']
u'Central European Summer Time'

.. versionadded:: 0.9

◆ min_week_days()

int babel.core.Locale.min_week_days (   self)
The minimum number of days in a week so that the week is counted as
the first week of a year or month.

>>> Locale('de', 'DE').min_week_days
4

◆ months()

localedata.LocaleDataDict babel.core.Locale.months (   self)
Locale display names for months.

>>> Locale('de', 'DE').months['format']['wide'][10]
u'Oktober'

◆ negotiate()

Locale | None babel.core.Locale.negotiate (   cls,
Iterable[str]  preferred,
Iterable[str]  available,
str   sep = '_',
Mapping[str, str]   aliases = LOCALE_ALIASES 
)
Find the best match between available and requested locale strings.

>>> Locale.negotiate(['de_DE', 'en_US'], ['de_DE', 'de_AT'])
Locale('de', territory='DE')
>>> Locale.negotiate(['de_DE', 'en_US'], ['en', 'de'])
Locale('de')
>>> Locale.negotiate(['de_DE', 'de'], ['en_US'])

You can specify the character used in the locale identifiers to separate
the different components. This separator is applied to both lists. Also,
case is ignored in the comparison:

>>> Locale.negotiate(['de-DE', 'de'], ['en-us', 'de-de'], sep='-')
Locale('de', territory='DE')

:param preferred: the list of locale identifiers preferred by the user
:param available: the list of locale identifiers available
:param aliases: a dictionary of aliases for locale identifiers
:param sep: separator for parsing; e.g. Windows tends to use '-' instead of '_'.

◆ number_symbols()

localedata.LocaleDataDict babel.core.Locale.number_symbols (   self)
Symbols used in number formatting by number system.

.. note:: The format of the value returned may change between
          Babel versions.

>>> Locale('fr', 'FR').number_symbols["latn"]['decimal']
u','
>>> Locale('fa', 'IR').number_symbols["arabext"]['decimal']
u'٫'
>>> Locale('fa', 'IR').number_symbols["latn"]['decimal']
u'.'

◆ ordinal_form()

PluralRule babel.core.Locale.ordinal_form (   self)
Plural rules for the locale.

>>> Locale('en').ordinal_form(1)
'one'
>>> Locale('en').ordinal_form(2)
'two'
>>> Locale('en').ordinal_form(3)
'few'
>>> Locale('fr').ordinal_form(2)
'other'
>>> Locale('ru').ordinal_form(100)
'other'

◆ other_numbering_systems()

localedata.LocaleDataDict babel.core.Locale.other_numbering_systems (   self)
Mapping of other numbering systems available for the locale.
See: https://www.unicode.org/reports/tr35/tr35-numbers.html#otherNumberingSystems

>>> Locale('el', 'GR').other_numbering_systems['traditional']
u'grek'

.. note:: The format of the value returned may change between
          Babel versions.

◆ parse()

Locale babel.core.Locale.parse (   cls,
Locale | str | None  identifier,
str   sep = '_',
bool   resolve_likely_subtags = True 
)
Create a `Locale` instance for the given locale identifier.

>>> l = Locale.parse('de-DE', sep='-')
>>> l.display_name
u'Deutsch (Deutschland)'

If the `identifier` parameter is not a string, but actually a `Locale`
object, that object is returned:

>>> Locale.parse(l)
Locale('de', territory='DE')

If the `identifier` parameter is neither of these, such as `None`
or an empty string, e.g. because a default locale identifier
could not be determined, a `TypeError` is raised:

>>> Locale.parse(None)
Traceback (most recent call last):
    ...
TypeError: ...

This also can perform resolving of likely subtags which it does
by default.  This is for instance useful to figure out the most
likely locale for a territory you can use ``'und'`` as the
language tag:

>>> Locale.parse('und_AT')
Locale('de', territory='AT')

Modifiers are optional, and always at the end, separated by "@":

>>> Locale.parse('de_AT@euro')
Locale('de', territory='AT', modifier='euro')

:param identifier: the locale identifier string
:param sep: optional component separator
:param resolve_likely_subtags: if this is specified then a locale will
                               have its likely subtag resolved if the
                               locale otherwise does not exist.  For
                               instance ``zh_TW`` by itself is not a
                               locale that exists but Babel can
                               automatically expand it to the full
                               form of ``zh_hant_TW``.  Note that this
                               expansion is only taking place if no
                               locale exists otherwise.  For instance
                               there is a locale ``en`` that can exist
                               by itself.
:raise `ValueError`: if the string does not appear to be a valid locale
                     identifier
:raise `UnknownLocaleError`: if no locale data is available for the
                             requested locale
:raise `TypeError`: if the identifier is not a string or a `Locale`
:raise `ValueError`: if the identifier is not a valid string

◆ percent_formats()

localedata.LocaleDataDict babel.core.Locale.percent_formats (   self)
Locale patterns for percent number formatting.

.. note:: The format of the value returned may change between
          Babel versions.

>>> Locale('en', 'US').percent_formats[None]
<NumberPattern u'#,##0%'>

◆ periods()

localedata.LocaleDataDict babel.core.Locale.periods (   self)
Locale display names for day periods (AM/PM).

>>> Locale('en', 'US').periods['am']
u'AM'

◆ plural_form()

PluralRule babel.core.Locale.plural_form (   self)
Plural rules for the locale.

>>> Locale('en').plural_form(1)
'one'
>>> Locale('en').plural_form(0)
'other'
>>> Locale('fr').plural_form(0)
'one'
>>> Locale('ru').plural_form(100)
'many'

◆ quarters()

localedata.LocaleDataDict babel.core.Locale.quarters (   self)
Locale display names for quarters.

>>> Locale('de', 'DE').quarters['format']['wide'][1]
u'1. Quartal'

◆ scientific_formats()

localedata.LocaleDataDict babel.core.Locale.scientific_formats (   self)
Locale patterns for scientific number formatting.

.. note:: The format of the value returned may change between
          Babel versions.

>>> Locale('en', 'US').scientific_formats[None]
<NumberPattern u'#E0'>

◆ scripts()

localedata.LocaleDataDict babel.core.Locale.scripts (   self)
Mapping of script codes to translated script names.

>>> Locale('en', 'US').scripts['Hira']
u'Hiragana'

See `ISO 15924 <https://www.unicode.org/iso15924/>`_
for more information.

◆ territories()

localedata.LocaleDataDict babel.core.Locale.territories (   self)
Mapping of script codes to translated script names.

>>> Locale('es', 'CO').territories['DE']
u'Alemania'

See `ISO 3166 <https://en.wikipedia.org/wiki/ISO_3166>`_
for more information.

◆ text_direction()

str babel.core.Locale.text_direction (   self)
The text direction for the language in CSS short-hand form.

>>> Locale('de', 'DE').text_direction
'ltr'
>>> Locale('ar', 'SA').text_direction
'rtl'

◆ time_formats()

localedata.LocaleDataDict babel.core.Locale.time_formats (   self)
Locale patterns for time formatting.

.. note:: The format of the value returned may change between
          Babel versions.

>>> Locale('en', 'US').time_formats['short']
<DateTimePattern u'h:mm\u202fa'>
>>> Locale('fr', 'FR').time_formats['long']
<DateTimePattern u'HH:mm:ss z'>

◆ time_zones()

localedata.LocaleDataDict babel.core.Locale.time_zones (   self)
Locale display names for time zones.

.. note:: The format of the value returned may change between
          Babel versions.

>>> Locale('en', 'US').time_zones['Europe/London']['long']['daylight']
u'British Summer Time'
>>> Locale('en', 'US').time_zones['America/St_Johns']['city']
u'St. John\u2019s'

◆ unit_display_names()

localedata.LocaleDataDict babel.core.Locale.unit_display_names (   self)
Display names for units of measurement.

.. seealso::

   You may want to use :py:func:`babel.units.get_unit_name` instead.

.. note:: The format of the value returned may change between
          Babel versions.

◆ variants()

localedata.LocaleDataDict babel.core.Locale.variants (   self)
Mapping of script codes to translated script names.

>>> Locale('de', 'DE').variants['1901']
u'Alte deutsche Rechtschreibung'

◆ weekend_end()

int babel.core.Locale.weekend_end (   self)
The day the weekend ends, with 0 being Monday.

>>> Locale('de', 'DE').weekend_end
6

◆ weekend_start()

int babel.core.Locale.weekend_start (   self)
The day the weekend starts, with 0 being Monday.

>>> Locale('de', 'DE').weekend_start
5

◆ zone_formats()

localedata.LocaleDataDict babel.core.Locale.zone_formats (   self)
Patterns related to the formatting of time zones.

.. note:: The format of the value returned may change between
          Babel versions.

>>> Locale('en', 'US').zone_formats['fallback']
u'%(1)s (%(0)s)'
>>> Locale('pt', 'BR').zone_formats['region']
u'Hor\\xe1rio %s'

.. versionadded:: 0.9

The documentation for this class was generated from the following file: