pub struct LangBe { /* private fields */ }Implementations§
Trait Implementations§
Source§impl Lang for LangBe
impl Lang for LangBe
Source§fn default_currency(&self) -> &str
fn default_currency(&self) -> &str
This language’s own to_currency(currency=...) default,
read from the live Python signature. Only 44 of 156 use EUR.
Source§fn default_separator(&self) -> &str
fn default_separator(&self) -> &str
This language’s own to_currency(separator=...) default,
read from the live Python signature. Base’s is “,”, but only
36 of 149 languages actually use it — most default to “ “ or a
conjunction, so inheriting Base’s comma silently corrupts them.
Source§fn to_cardinal(&self, value: &BigInt) -> Result<String>
fn to_cardinal(&self, value: &BigInt) -> Result<String>
Port of Num2Word_BE.to_cardinal, integer path only.
Python stringifies the input and branches on "." in n; str(int)
never contains one, so integers always take the else branch:
self._int2word(int(n), gender). The float branch (pointword,
leading-zero padding) is out of scope.
Source§fn to_ordinal(&self, value: &BigInt) -> Result<String>
fn to_ordinal(&self, value: &BigInt) -> Result<String>
Port of Num2Word_BE.to_ordinal, with Python’s default gender="m".
Source§fn ordinal_float_entry(&self, value: &FloatValue) -> Result<String>
fn ordinal_float_entry(&self, value: &FloatValue) -> Result<String>
to_ordinal(float/Decimal) — Base’s verify_ordinal, then BE’s own
to_cardinal string branch, then the last-word ordinal machinery.
verify_ordinal is numeric, not a type check:
if not value == int(value): raise TypeError(errmsg_floatord % value)
if not abs(value) == value: raise TypeError(errmsg_negord % value)so whole floats pass and get their “.0” tail ordinalised
(to_ordinal(5.0) == "пяць коска нулявы"), -0.0 passes both checks
(abs(-0.0) == -0.0 numerically) and keeps its negword, fractional
values are the floatord TypeError, and true negatives the negord one
— first check wins for -1.5. inf/nan die inside int(value) itself.
%s % value is str(value), i.e. [py_repr_float]/[py_str_decimal].
Source§fn str_to_number(&self, s: &str) -> Result<ParsedNumber>
fn str_to_number(&self, s: &str) -> Result<ParsedNumber>
BE inherits Base’s str_to_number (Decimal(value)), which parses
“Infinity”/“NaN” successfully — the failure Python shows for
num2words("Infinity", lang="be") happens later, per mode, and is
served natively by Lang::inf_result / Lang::nan_result below.
So the parse itself just passes the ParsedNumber::Inf/NaN through.
Source§fn inf_result(&self, negative: bool, to: &str) -> Result<String>
fn inf_result(&self, negative: bool, to: &str) -> Result<String>
Decimal('Infinity') / -Infinity reached BE. Behaviour is per mode,
exactly as the original converter produces it:
cardinal/yearfeed the raw token toint("Infinity")inside BE’s ownto_cardinal→ValueError.ordinalfirst runs Base’sverify_ordinal, whoseint(Decimal('Infinity'))raisesOverflowError.ordinal_numinherits Base’s identityto_ordinal_num, so the value is echoed unchanged (str(Decimal('Infinity'))).
Source§fn nan_result(&self, to: &str) -> Result<String>
fn nan_result(&self, to: &str) -> Result<String>
Decimal('NaN') reached BE. cardinal/year die in int("NaN")
(ValueError); ordinal’s verify_ordinal does int(Decimal('NaN')),
also ValueError; ordinal_num echoes the value unchanged.
Source§fn to_cardinal_kw(&self, value: &BigInt, kw: &Kwargs) -> Result<String>
fn to_cardinal_kw(&self, value: &BigInt, kw: &Kwargs) -> Result<String>
to_cardinal(number, gender="m") with an explicit kwargs bag.
Source§fn to_ordinal_kw(&self, value: &BigInt, kw: &Kwargs) -> Result<String>
fn to_ordinal_kw(&self, value: &BigInt, kw: &Kwargs) -> Result<String>
to_ordinal(number, gender="m") with an explicit kwargs bag.
Source§fn to_year_kw(&self, value: &BigInt, _kw: &Kwargs) -> Result<String>
fn to_year_kw(&self, value: &BigInt, _kw: &Kwargs) -> Result<String>
Base’s to_year(self, value, **kwargs): the catch-all accepts any
kwargs and reads none of them, then returns self.to_cardinal(value)
— BE’s override with its default gender="m". So
to_year(5, gender="f") is “пяць”, not “пяць” feminised and not a
TypeError; deliberately no kw.only guard.
Source§fn to_cardinal_float_kw(
&self,
value: &FloatValue,
_precision_override: Option<u32>,
kw: &Kwargs,
) -> Result<String>
fn to_cardinal_float_kw( &self, value: &FloatValue, _precision_override: Option<u32>, kw: &Kwargs, ) -> Result<String>
to_cardinal(float/Decimal, gender=...) — same string branch as
Lang::to_cardinal_float, with the caller’s gender threaded into
both int(left) and int(right) renderings, exactly as Python’s
single gender parameter reaches both _int2word calls.
Source§fn to_cardinal_float(
&self,
value: &FloatValue,
_precision_override: Option<u32>,
) -> Result<String>
fn to_cardinal_float( &self, value: &FloatValue, _precision_override: Option<u32>, ) -> Result<String>
The float/Decimal cardinal surface.
BE does not override to_cardinal_float; num2words hands the float
straight to Num2Word_BE.to_cardinal(number), whose first act is
str(number). So this hook exists only to re-derive that string and
re-enter the real method — the Base implementation this replaces
(float2tuple + digit-by-digit spelling) is never executed for BE.
gender is “m”: the dispatcher calls to_cardinal(number) positionally
and Python’s default applies.
_precision_override is ignored on purpose. num2words assigns
converter.precision for the precision= kwarg, but BE’s to_cardinal
reads only the string — num2words(1.5, lang='be', precision=3) is
“адзін коска пяць”, unchanged (verified live). Honouring it here would
invent behaviour Python does not have.
Source§fn pluralize(&self, n: &BigInt, forms: &[String]) -> Result<String>
fn pluralize(&self, n: &BigInt, forms: &[String]) -> Result<String>
Num2Word_BE.pluralize — the trait-facing half; see [plural_form_index].
Python indexes the tuple directly, so a form list shorter than the
chosen index raises IndexError. Every BE entry has exactly three forms
on both sides, so that is unreachable — but it is mapped to
N2WError::Index rather than panicking, so the exception type survives
if the table is ever edited down.
Source§fn money_verbose(&self, number: &BigInt, currency: &str) -> Result<String>
fn money_verbose(&self, number: &BigInt, currency: &str) -> Result<String>
Port of Num2Word_BE._money_verbose: the hryvnia is feminine, every
other unit masculine.
Calls _int2word directly, as Python does — not to_cardinal, which
would pin the gender back to “m” and lose the distinction
(to_currency(1.0, "UAH") → “адна грыўна”, not “адзін грыўна”).
Source§fn cents_verbose(&self, number: &BigInt, currency: &str) -> Result<String>
fn cents_verbose(&self, number: &BigInt, currency: &str) -> Result<String>
Port of Num2Word_BE._cents_verbose.
The gender set differs from _money_verbose’s: the subunit is
feminine for UAH, RUB and BYN alike (all three use “капейка”), even
though RUB’s and BYN’s units are masculine rubles. So
to_currency(1.01, "RUB") is “адзін расійскі рубель, адна капейка” —
masculine unit, feminine cent, in one string.
Source§fn cardinal_float_entry(
&self,
value: &FloatValue,
precision_override: Option<u32>,
) -> Result<String>
fn cardinal_float_entry( &self, value: &FloatValue, precision_override: Option<u32>, ) -> Result<String>
to_cardinal(float/Decimal) — the full entry, whole values included.fn negword(&self) -> &str
fn pointword(&self) -> &str
Source§fn currency_forms(&self, code: &str) -> Option<&CurrencyForms>
fn currency_forms(&self, code: &str) -> Option<&CurrencyForms>
CURRENCY_FORMS[code]. None -> NotImplementedError, as in Python.fn cards(&self) -> &Cards
fn maxval(&self) -> &BigInt
fn is_title(&self) -> bool
fn exclude_title(&self) -> &[String]
Source§fn merge(&self, _l: (&str, &BigInt), _r: (&str, &BigInt)) -> (String, BigInt)
fn merge(&self, _l: (&str, &BigInt), _r: (&str, &BigInt)) -> (String, BigInt)
merge is abstract in Python (raise NotImplementedError).
Languages that override to_cardinal never reach it.fn title(&self, value: &str) -> String
fn to_ordinal_num(&self, value: &BigInt) -> Result<String>
fn to_year(&self, value: &BigInt) -> Result<String>
Source§fn currency_precision(&self, _code: &str) -> i64
fn currency_precision(&self, _code: &str) -> i64
CURRENCY_PRECISION.get(code, 100) — subunits per unit. 1000 for
3-decimal currencies (BHD/KWD/…), 1 for no-subunit currencies.fn cents_terse(&self, number: &BigInt, currency: &str) -> Result<String>
Source§fn cardinal_from_decimal(&self, value: &BigDecimal) -> Result<String>
fn cardinal_from_decimal(&self, value: &BigDecimal) -> Result<String>
self.to_cardinal(float(right)), i.e. through the
float path, so the default routes there rather than raising.Source§fn to_currency(
&self,
val: &CurrencyValue,
currency: &str,
cents: bool,
separator: Option<&str>,
adjective: bool,
) -> Result<String>
fn to_currency( &self, val: &CurrencyValue, currency: &str, cents: bool, separator: Option<&str>, adjective: bool, ) -> Result<String>
separator: None means the caller omitted the kwarg, so the
language’s own default applies. Python expresses this as a per-method
default (Num2Word_CA.to_currency(..., separator=" amb")), which a
plain &str cannot represent: once the shim substitutes Base’s “,”,
“caller omitted it” and “caller passed a comma” are indistinguishable.Source§fn default_adjective(&self) -> bool
fn default_adjective(&self) -> bool
to_currency(adjective=...) default. Base’s is
False; only Mongolian defaults to True.fn to_cheque(&self, val: &BigDecimal, currency: &str) -> Result<String>
Source§fn to_fraction(
&self,
numerator: &BigInt,
denominator: &BigInt,
) -> Result<String>
fn to_fraction( &self, numerator: &BigInt, denominator: &BigInt, ) -> Result<String>
Num2Word_Base.to_fraction (issue #584). EN/DE/ES/FR/IT/PT and the
aero profiles override with idiomatic forms (half/quarter/Drittel).Source§fn ordinal_num_float_entry(
&self,
_value: &FloatValue,
repr_str: &str,
) -> Result<String>
fn ordinal_num_float_entry( &self, _value: &FloatValue, repr_str: &str, ) -> Result<String>
to_ordinal_num(float/Decimal). Base returns the value unchanged and
the dispatcher str()s it, so the default echoes the Python repr the
binding computed.Source§fn year_float_entry(&self, value: &FloatValue) -> Result<String>
fn year_float_entry(&self, value: &FloatValue) -> Result<String>
to_year(float/Decimal). Base’s to_year is to_cardinal.Source§fn cardinal_with_pointword(
&self,
_value: &FloatValue,
_pointword: &str,
_precision_override: Option<u32>,
) -> Result<String>
fn cardinal_with_pointword( &self, _value: &FloatValue, _pointword: &str, _precision_override: Option<u32>, ) -> Result<String>
to_cardinal(value) with the pointword
swapped for this one call. Only reachable through
ParsedNumber::DecPoint, so only PT_BR implements it.fn to_ordinal_num_kw(&self, value: &BigInt, kw: &Kwargs) -> Result<String>
fn to_currency_kw( &self, val: &CurrencyValue, currency: &str, cents: bool, separator: Option<&str>, adjective: bool, kw: &Kwargs, ) -> Result<String>
Source§fn es_currency_ordinal_fires(&self) -> bool
fn es_currency_ordinal_fires(&self) -> bool
Num2Word_ES
apocopates 1 → “un euro” in to_currency, bypassing to_cardinal, so
the stash never fires (false, the default). The regional es_XX
classes inherit Base.to_currency, whose _money_verbose calls
to_cardinal(1) → the stash fires → “primero córdoba” (true).Source§fn neg_zero_decimal(&self, _to: &str) -> Option<Result<String>>
fn neg_zero_decimal(&self, _to: &str) -> Option<Result<String>>
Decimal('-0.0') for mode to, which BigDecimal cannot
represent (it has no signed zero). None — the default — means the
value coincides with float -0.0, so the binding’s Float{-0.0}
demotion is exact. The ~10 languages that render the Decimal form
differently (ce/cy “dim”/“ноль” via the integer path, pl its float
grammar with the negword, rm a TypeError) override this to serve it
natively instead of leaning on a Python fallback.Source§fn python_maxval(&self) -> Option<BigInt>
fn python_maxval(&self) -> Option<BigInt>
getattr(converter, "MAXVAL", None) — the maxval() API.
Engine languages get it from their card table (Base sets
MAXVAL = 1000 * top_card); self-contained ones mostly lack the
attribute (None). The zero sentinel in maxval() means “unset”.