44
55Convert number like ` 42 ` to ` forty-two `
66
7+ ## Usage
8+
9+ This crate can be either used as a library or a binary.
10+
11+ ### Library
12+
713Example usage:
14+
815``` rust
916use num2words :: Num2Words ;
1017assert_eq! (Num2Words :: new (42 ). to_words (), Ok (String :: from (" forty-two" )));
1118```
1219
13- The app can also be run via a command-line interface.
20+ The builder Num2Words can take three arguments: ` lang ` , ` output ` and
21+ ` currency ` .
22+
23+ ``` rust
24+ use num2words :: * ;
25+ assert_eq! (
26+ Num2Words :: new (42 ). lang (Lang :: English ). to_words (),
27+ Ok (String :: from (" forty-two" ))
28+ );
29+ assert_eq! (
30+ Num2Words :: new (42 ). output (Output :: Ordinal ). to_words (),
31+ Ok (String :: from (" forty-second" ))
32+ );
33+ assert_eq! (
34+ Num2Words :: new (42.01 ). currency (Currency :: DOLLAR ). to_words (),
35+ Ok (String :: from (" forty-two dollars and one cent" ))
36+ );
37+ ```
38+
39+ These arguments can be chained.
40+
41+ For more information about the available languages, outputs and currencies,
42+ see [ Informations] ( #informations ) .
43+
44+ ### Binary
45+
46+ This crate provides a command-line interface to run requests on ` num2words ` .
1447
1548Example:
1649``` sh
@@ -25,24 +58,63 @@ You can download the app via the following command:
2558$ cargo install num2words
2659```
2760
28- For more information about the usage of ` num2words ` please refers to the
29- docs or via the following command:
61+ You can also change the language via the argument ` --lang ` and provide an
62+ output or a currency with the argument ` --to ` .
63+
64+ For more information about the usage of ` num2words ` please refer to the docs
65+ or via the following command:
3066``` sh
3167$ num2words --help
3268```
3369
70+ ## Informations
71+
72+ ### Supported languages
73+
74+ Here is a list of all of the supported languages:
75+
76+ | Flag | Code | CLI code | Language | 42 |
77+ | ---- | --------------- | --------------- | -------- | --------- |
78+ | 🇺🇸🇬🇧 | ` Lang::English ` | ` en ` | English | forty-two |
79+
80+ This list can be expanded! Contributions are welcomed.
81+
82+ ### Supported output
83+
84+ Here is a list of all of the supported outputs (with the command-line
85+ interface code):
86+
87+ - ` Output::Cardinal ` (` cardinal ` ): forty-two (42)
88+ - ` Output::Currency ` (any available currencies): forty-two dollars and one
89+ cent (42.01)
90+ - ` Output::Ordinal ` (` ordinal ` ): forty-second (42)
91+ - ` Output::OrdinalNum ` (` ordinal_num ` ): 42nd (42)
92+ - ` Output::Year ` (` year ` ): nineteen oh-one (1901)
93+
94+ ### Supported currencies
95+
96+ Here is a list of all of the supported currencies (with the command-line
97+ interface code):
98+
99+ - ` Currency::AUD ` (` AUD ` ): australian dollar
100+ - ` Currency::CAD ` (` CAD ` ): canadian dollar
101+ - ` Currency::DOLLAR ` (` DOLLAR ` ): dollar
102+ - ` Currency::EUR ` (` EUR ` ): euro
103+ - ` Currency::GBP ` (` GBP ` ): pound
104+ - ` Currency::USD ` (` USD ` ): US dollar
105+
106+ ### About
107+
34108This library is widely inspired by [ Savoir-faire Linux's Python
35109lib] ( https://github.com/savoirfairelinux/num2words/ ) .
36110
37- ** Warning** : this lib is not usable at its current state, we would recommend
38- you come back later.
39-
40111## License
41112
42113Licensed under either of
43114
44115- Apache License, Version 2.0
45- ([ LICENSE-APACHE] ( LICENSE-APACHE ) or http://www.apache.org/licenses/LICENSE-2.0 )
116+ ([ LICENSE-APACHE] ( LICENSE-APACHE ) or
117+ http://www.apache.org/licenses/LICENSE-2.0 )
46118- MIT license
47119 ([ LICENSE-MIT] ( LICENSE-MIT ) or http://opensource.org/licenses/MIT )
48120
@@ -51,5 +123,5 @@ at your option.
51123## Contribution
52124
53125Unless you explicitly state otherwise, any contribution intentionally submitted
54- for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
55- dual licensed as above, without any additional terms or conditions.
126+ for inclusion in the work by you, as defined in the Apache-2.0 license,
127+ shall be dual licensed as above, without any additional terms or conditions.
0 commit comments