![]() |
Qucs-S S-parameter Viewer & RF Synthesis Tools
|
Public Member Functions | |
| None | __init__ (self, Mapping[str, str]|Iterable[tuple[str, str]] rules) |
| str | __repr__ (self) |
| PluralRule | parse (cls, Mapping[str, str]|Iterable[tuple[str, str]]|PluralRule rules) |
| Mapping[str, str] | rules (self) |
| frozenset[str] | tags (self) |
| list[tuple[str, Any]] | __getstate__ (self) |
| None | __setstate__ (self, list[tuple[str, Any]] abstract) |
| str | __call__ (self, float|decimal.Decimal n) |
Public Attributes | |
| abstract | |
Protected Attributes | |
| _func | |
Represents a set of language pluralization rules. The constructor
accepts a list of (tag, expr) tuples or a dict of `CLDR rules`_. The
resulting object is callable and accepts one parameter with a positive or
negative number (both integer and float) for the number that indicates the
plural form for a string and returns the tag for the format:
>>> rule = PluralRule({'one': 'n is 1'})
>>> rule(1)
'one'
>>> rule(2)
'other'
Currently the CLDR defines these tags: zero, one, two, few, many and
other where other is an implicit default. Rules should be mutually
exclusive; for a given numeric value, only one rule should apply (i.e.
the condition should only be true for one of the plural rule elements.
.. _`CLDR rules`: https://www.unicode.org/reports/tr35/tr35-33/tr35-numbers.html#Language_Plural_Rules
| None babel.plural.PluralRule.__init__ | ( | self, | |
| Mapping[str, str] | Iterable[tuple[str, str]] | rules | ||
| ) |
Initialize the rule instance.
:param rules: a list of ``(tag, expr)``) tuples with the rules
conforming to UTS #35 or a dict with the tags as keys
and expressions as values.
:raise RuleError: if the expression is malformed
| PluralRule babel.plural.PluralRule.parse | ( | cls, | |
| Mapping[str, str] | Iterable[tuple[str, str]] | PluralRule | rules | ||
| ) |
Create a `PluralRule` instance for the given rules. If the rules are a `PluralRule` object, that object is returned. :param rules: the rules as list or dict, or a `PluralRule` object :raise RuleError: if the expression is malformed
| Mapping[str, str] babel.plural.PluralRule.rules | ( | self | ) |
The `PluralRule` as a dict of unicode plural rules.
>>> rule = PluralRule({'one': 'n is 1'})
>>> rule.rules
{'one': 'n is 1'}
| frozenset[str] babel.plural.PluralRule.tags | ( | self | ) |
A set of explicitly defined tags in this rule. The implicit default ``'other'`` rules is not part of this set unless there is an explicit rule for it.