1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
//! Numbers to words in 50 languages (72 regional variants).
//!
//! A Rust port of the [n2words](https://github.com/forzagreen/n2words)
//! JavaScript library. Each language is a module named after its BCP 47 code
//! in snake_case, exposing up to three **forms**:
//!
//! | Form | Function | Example |
//! |----------|----------------------------------|-------------------------------------|
//! | Cardinal | [`en::to_cardinal`] | "forty-two" |
//! | Ordinal | [`en::to_ordinal`] | "forty-second" |
//! | Currency | [`en_us::to_currency`] | "forty-two dollars and fifty cents" |
//!
//! ```
//! use n2words::{en, en_us, es, fr, Currency};
//!
//! assert_eq!(en::to_cardinal(42)?, "forty-two");
//! assert_eq!(en::to_ordinal(42)?, "forty-second");
//! assert_eq!(es::to_cardinal(42)?, "cuarenta y dos");
//! assert_eq!(fr::to_cardinal("1234.5")?, "mille deux cent trente-quatre virgule cinq");
//!
//! // A region-qualified code carries a default currency ...
//! assert_eq!(en_us::to_currency(42.5)?, "forty-two dollars and fifty cents");
//! // ... while a bare language tag has no country to take one from, so it is explicit.
//! assert_eq!(en::to_currency(42.5, Currency::GBP)?, "forty-two pounds and fifty pence");
//! # Ok::<(), n2words::Error>(())
//! ```
//!
//! # Input
//!
//! Every function takes `impl Into<`[`Number`]`>`: any primitive integer, an
//! `f64`/`f32`, a numeric `&str`/`String` (arbitrary precision, scientific
//! notation accepted) or a [`num_bigint::BigInt`]/`BigUint`. Cardinal and
//! currency accept negatives and decimals; ordinal takes positive integers.
//!
//! # Options
//!
//! A form that has options comes in two flavours: `to_cardinal(value)` with
//! the language's defaults, and `to_cardinal_with(value, &options)` taking a
//! per-language options struct whose `Default` *is* those defaults:
//!
//! ```
//! use n2words::en_us::{self, CardinalOptions};
//!
//! assert_eq!(en_us::to_cardinal(1501)?, "one thousand five hundred one");
//! let informal = CardinalOptions { and: true, hundred_pairing: true, ..Default::default() };
//! assert_eq!(en_us::to_cardinal_with(1501, &informal)?, "fifteen hundred and one");
//! # Ok::<(), n2words::Error>(())
//! ```
//!
//! # Range
//!
//! Each form spells values up to the largest scale word it knows, declared as
//! a [`Max`] constant (`en_us::CARDINAL_MAX` is `10^66`), and returns
//! [`Error::OutOfRange`] past it rather than inventing vocabulary.
//!
//! # Picking a language at runtime
//!
//! [`language()`] looks an entry point up by code and gives access to the same
//! conversions through string-keyed options, which is what the `n2words`
//! command-line tool is built on:
//!
//! ```
//! use n2words::{language, FormKind};
//!
//! let de = language("de").expect("German is supported");
//! assert_eq!(de.convert(FormKind::Cardinal, 42, &[])?, "zweiundvierzig");
//! assert_eq!(de.convert(FormKind::Currency, "42.50", &[("currency", "EUR")])?, "zweiundvierzig Euro und fünfzig Cent");
//! # Ok::<(), n2words::Error>(())
//! ```
//!
//! # Languages
//!
//! Most languages are reachable through a bare primary subtag (`de`, `en`,
//! `fr`, ...), a documented alias of one specific regional variant; the
//! region- or script-qualified module always exists too (`en_gb`, `fr_be`),
//! and is the only entry point for the few languages whose variants differ in
//! script or core numbering (`zh_hans_cn`/`zh_hant_tw`, `pt_br`/`pt_pt`,
//! `sr_cyrl_rs`/`sr_latn_rs`, `am_et`/`am_latn_et`). See `LANGUAGES.md` in
//! the repository for the full table, per-language options and ceilings.
pub use num_bigint;
pub use Currency;
pub use ;
pub use *;
pub use ;
pub use Max;
pub use Number;
pub use Gender;
/// The crate version, as published.
pub const VERSION: &str = env!;