#text #numbers #french

french-numbers

Represent numbers in French language

16 releases (3 stable)

✓ Uses Rust 2018 edition

1.1.0 Dec 16, 2018
1.0.1 Sep 27, 2018
0.1.12 Sep 18, 2018
0.1.10 May 28, 2018
0.1.5 Apr 24, 2017

#18 in Value formatting

Download history 38/week @ 2019-11-27 32/week @ 2019-12-04 33/week @ 2019-12-11 1/week @ 2019-12-18 16/week @ 2019-12-25 160/week @ 2020-01-08 64/week @ 2020-01-15 2/week @ 2020-01-29 2/week @ 2020-02-05 18/week @ 2020-02-12 33/week @ 2020-02-19 39/week @ 2020-02-26 32/week @ 2020-03-04 16/week @ 2020-03-11

97 downloads per month
Used in numbers

Apache-2.0/MIT

110KB
352 lines

french-numbers

Unix build Status Windows build Status Current Version Documentation License: Apache-2.0/MIT

This crate transforms a number into its French representation.

Using this crate

In your Cargo.toml, put:

[dependencies]
french-numbers = "1.1"

You can then use the french_number function from the french_numbers crate to format any integer into the beautiful French romance language:

use french_numbers::french_number;

assert_eq!(french_number(&71), "soixante-et-onze");
assert_eq!(french_number(&1001), "mille-un");
assert_eq!(french_number(&-200001), "moins deux-cent-mille-un");
assert_eq!(french_number(&-200000001), "moins deux-cents-millions-un");
assert_eq!(french_number(&-204000001), "moins deux-cent-quatre-millions-un");

You can also request the use of the feminine form, or prefer the previous way of writing numbers predating the 1990 orthographic reform:

use french_numbers::*;

assert_eq!(french_number_options(&37251061, &POST_REFORM_MASCULINE),
           "trente-sept-millions-deux-cent-cinquante-et-un-mille-soixante-et-un");
assert_eq!(french_number_options(&37251061, &POST_REFORM_FEMININE),
           "trente-sept-millions-deux-cent-cinquante-et-un-mille-soixante-et-une");
assert_eq!(french_number_options(&37251061, &PRE_REFORM_FEMININE),
           "trente-sept millions deux cent cinquante et un mille soixante et une");
assert_eq!(french_number_options(&37251061, &PRE_REFORM_MASCULINE),
           "trente-sept millions deux cent cinquante et un mille soixante et un")

An example program can dump particular number, with different options:

% cargo run --example french-number -- --help
Print number(s) in French

USAGE:
    french-number [FLAGS] <LOW> [HIGH]

FLAGS:
    -f, --feminine     use the feminine declination
    -h, --help         Prints help information
    -r, --no-reform    use the pre-1990 orthographic reform writing
    -p, --prefix       prefix output with the numerical representation
    -V, --version      Prints version information

ARGS:
    <LOW>     number (or low bound) to use
    <HIGH>    optional high bound

Dependencies