Spelling a number
The SpellingFormatter is used to spellout a number (long, decimal or double) in a locale specific manner. The Create method is used to create a formatter for a specific locale and a set of options.
var locale = Locale.Create("fr");
var formatter = SpellingFormatter.Create(locale);
Assert.AreEqual("moins un", formatter.Format(-1));
Assert.AreEqual("zéro", formatter.Format(0));
Assert.AreEqual("vingt-et-un", formatter.Format(21));
Assert.AreEqual("quatre-vingt-dix-neuf", formatter.Format(99));
Assert.AreEqual("un virgule deux", formatter.Format(1.2));
Options
SpellingOptions are used to determine the style for spelling out a number.
Style | en | fr |
---|---|---|
Cardinal | one | un |
Ordinal | first | unième |