pub struct LangDa { /* private fields */ }Implementations§
Trait Implementations§
Source§impl Lang for LangDa
impl Lang for LangDa
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 ordinal_float_entry(&self, value: &FloatValue) -> Result<String>
fn ordinal_float_entry(&self, value: &FloatValue) -> Result<String>
to_ordinal(float/Decimal): verify_ordinal, then the integer path.
Whole values ordinalise (5.0 -> “femte”, Decimal(“1E+2”) ->
“ethundredete”, -0.0 -> “nulte”); fractional or negative values raise
TypeError (see module docs, bug 11). value % 100 on a non-negative
whole float/Decimal equals the integer mod, so delegating to the
BigInt to_ordinal (ordflag engine + ords scan + suffix) is exact.
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): str(value) + the % 100 suffix.
The numeric half is Python’s str(value) (repr_str), so
Decimal(“5.00”) yields “5.00te”, 2.0 yields “2.0en”, 1e+16 yields
“1e+16te” and -0.0 yields “-0.0te”.
Source§fn year_float_entry(&self, value: &FloatValue) -> Result<String>
fn year_float_entry(&self, value: &FloatValue) -> Result<String>
Num2Word_DA.to_year(float/Decimal) — see module docs, bugs 12/13.
if val == 1: return "en"
if not (val // 100) % 10: return self.to_cardinal(val)
return self.to_splitnum(val, hightxt="hundrede", longval=longval)The guard’s // floors for floats but truncates for Decimals, and
to_splitnum’s float branch is float2tuple (int part / fractional
digits) while its Decimal branch is divmod(val, 100) — four
distinct behaviours from three lines of Python, all load-bearing:
100.0 -> “ethundrede hundrede”, Decimal(‘100’) -> “et hundrede”,
-1.5 -> “minus et hundrede fem”, Decimal(‘-3.0’) -> “minus tre”.
Source§fn pluralize(&self, n: &BigInt, forms: &[String]) -> Result<String>
fn pluralize(&self, n: &BigInt, forms: &[String]) -> Result<String>
Num2Word_EUR.pluralize: forms[0 if n == 1 else 1].
Python indexes the tuple directly, so a one-form entry with n != 1
would raise IndexError. Every DA entry is a 2-tuple, making that
unreachable — mapped to Index rather than a panic so the exception
type survives if the table ever changes.
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>
Num2Word_DA.to_currency.
Python special-cases isinstance(val, int) to print the unit with no
cents segment, and hands everything else — including whole floats like
1.0 — to super(). That int/float split is exactly the
CurrencyValue split, so it maps across directly.
The longval=True parameter in the Python signature is accepted and
then never read; there is nothing to port.
fn cards(&self) -> &Cards
fn maxval(&self) -> &BigInt
fn negword(&self) -> &str
fn pointword(&self) -> &str
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 to_ordinal(&self, value: &BigInt) -> Result<String>
fn to_ordinal_num(&self, value: &BigInt) -> Result<String>
fn to_year(&self, value: &BigInt) -> Result<String>
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 is_title(&self) -> bool
fn title(&self, value: &str) -> String
fn to_cardinal(&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 money_verbose(&self, number: &BigInt, _currency: &str) -> Result<String>
fn cents_verbose(&self, number: &BigInt, _currency: &str) -> Result<String>
fn cents_terse(&self, number: &BigInt, currency: &str) -> Result<String>
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>
Num2Word_Base.to_cardinal_float. precision_override is the
precision= kwarg (issue #580).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 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 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.Source§fn str_to_number(&self, s: &str) -> Result<ParsedNumber>
fn str_to_number(&self, s: &str) -> Result<ParsedNumber>
converter.str_to_number. Base is Decimal(value); ES (“1ro” ->
ordinal handshake), PT_BR (“1.50” -> ‘ponto’), DV (TypeError instead
of InvalidOperation), BN (abs()) and ID override.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_cardinal_kw(&self, value: &BigInt, kw: &Kwargs) -> Result<String>
fn to_ordinal_kw(&self, value: &BigInt, kw: &Kwargs) -> Result<String>
fn to_ordinal_num_kw(&self, value: &BigInt, kw: &Kwargs) -> Result<String>
fn to_year_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>
fn to_cardinal_float_kw( &self, value: &FloatValue, precision_override: Option<u32>, 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 inf_result(&self, _negative: bool, _to: &str) -> Result<String>
fn inf_result(&self, _negative: bool, _to: &str) -> Result<String>
str_to_number produced Decimal('Infinity') / -Infinity. Base’s
integer path does int(Decimal('Infinity')) → OverflowError. The many
self-contained converters that feed the raw token to int("Infinity")
get ValueError instead and override this. to is the requested mode.Source§fn nan_result(&self, _to: &str) -> Result<String>
fn nan_result(&self, _to: &str) -> Result<String>
str_to_number produced Decimal('NaN'). Base’s int(NaN) raises
ValueError (caught into the float path, which raises ValueError again).
Languages whose parse raises decimal.InvalidOperation first override.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”.