NumWordify 1.0.0

dotnet add package NumWordify --version 1.0.0
                    
NuGet\Install-Package NumWordify -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NumWordify" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NumWordify" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="NumWordify" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NumWordify --version 1.0.0
                    
#r "nuget: NumWordify, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package NumWordify@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NumWordify&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=NumWordify&version=1.0.0
                    
Install as a Cake Tool

NumWordify

NumWordify is a .NET library that converts decimal numbers into words with multi-language and multi-currency support.

Features

  • Convert numbers to words with currency support
  • Convert decimal numbers to words without currency
  • Multi-language support (currently supports English, Turkish, French, and Spanish)
  • Multi-currency support (USD, TRY, EUR, and custom currencies)
  • Culture-based conversions (supports both string culture codes and CultureInfo)
  • Special number handling (e.g., "eleven", "twelve" in English)
  • Compound number formatting (e.g., "twenty-one" vs "twenty one")
  • Customizable formatting and separators
  • Negative number support
  • Zero handling
  • Extensible localization through JSON files
  • Caching support for better performance

Installation

You can install NumWordify via NuGet:

dotnet add package NumWordify

Usage

Basic Usage

using NumWordify.Extensions;
using System.Globalization;

decimal amount = 1234.56M;

// Using string culture code
string result1 = amount.ToWords("tr-TR");
// Output: "BİN İKİ YÜZ OTUZ DÖRT TL ELLİ ALTI Kr"

// Using CultureInfo
var culture = new CultureInfo("tr-TR");
string result2 = amount.ToWords(culture);
// Output: "BİN İKİ YÜZ OTUZ DÖRT TL ELLİ ALTI Kr"

// Using current culture
string result3 = amount.ToWords(CultureInfo.CurrentCulture);

// Convert to words with custom currency
var euroCurrency = new CurrencyModel { Major = "EURO", Minor = "CENT" };
string euroResult = amount.ToWords("tr-TR", euroCurrency);
// Output: "BİN İKİ YÜZ OTUZ DÖRT EURO ELLİ ALTI CENT"

// Convert to words without currency
string numberOnly = amount.ToWordsWithoutCurrency("tr-TR");
// Output: "BİN İKİ YÜZ OTUZ DÖRT NOKTA ELLİ ALTI"

Special Number Handling

NumWordify supports special number cases in different languages:

decimal amount = 11234.56M;
string result = amount.ToWords("en-US");
// Output: "ELEVEN THOUSAND TWO HUNDRED THIRTY-FOUR DOLLARS FIFTY-SIX CENTS"

// Note how it uses:
// - Special word "ELEVEN" instead of "TEN ONE"
// - Hyphenated compound numbers "THIRTY-FOUR"

Negative Numbers

decimal amount = -1234.56M;
string result = amount.ToWords("tr-TR");
// Output: "EKSİ BİN İKİ YÜZ OTUZ DÖRT TL ELLİ ALTI Kr"

Zero Handling

decimal amount = 0M;
string result = amount.ToWords("tr-TR");
// Output: "SIFIR TL SIFIR Kr"

Custom Localization

You can create your own localization model for any language and currency. Here's an example for Japanese Yen:

using NumWordify.Extensions;
using NumWordify.Models;

// Create custom localization model
var japaneseLocalization = new LocalizationModel
{
    Currency = new CurrencyModel
    {
        Major = "YEN",
        Minor = "SEN"
    },
    Numbers = new NumbersModel
    {
        Ones = new[] { "", "ICHI", "NI", "SAN", "YON", "GO", "ROKU", "NANA", "HACHI", "KYU" },
        Tens = new[] { "", "JU", "NIJU", "SANJU", "YONJU", "GOJU", "ROKUJU", "NANAJU", "HACHIJU", "KYUJU" },
        Hundreds = new[] { "", "HYAKU", "NIHYAKU", "SANBYAKU", "YONHYAKU", "GOHYAKU", "ROPPYAKU", "NANAHYAKU", "HAPPYAKU", "KYUHYAKU" },
        Scales = new[] { "", "SEN", "MAN", "OKU", "CHO", "KEI" }
    },
    Settings = new SettingsModel
    {
        SkipOneForThousand = true,
        SkipOneForHundred = true,
        NegativeWord = "MAINASU",
        ZeroWord = "ZERO",
        CurrencyFormat = "{whole} {major}",
        NumberFormat = "{whole} TEN {decimal}",
        UseTeens = false,
        UseCompoundNumbers = false
    }
};

decimal amount = 1234.56M;
string result = amount.ToWords(japaneseLocalization);
// Output: "SEN NIHYAKU SANJU YON YEN"

Supported Cultures

Culture Code Language Currency Special Features
en-US English US Dollar (USD) Teens (11-19), Compound numbers
tr-TR Turkish Turkish Lira (TRY) Skip "bir" for hundreds
fr-FR French Euro (EUR) -
es-ES Spanish Euro (EUR) -

Adding New Languages

To add a new language, create a JSON file in the Resources folder with the following structure:

{
  "currency": {
    "major": "USD",
    "minor": "Cents"
  },
  "settings": {
    "skipOneForThousand": false,
    "skipOneForHundred": false,
    "negativeWord": "NEGATIVE",
    "zeroWord": "ZERO",
    "currencyFormat": "{whole} {major} {decimal} {minor}",
    "numberFormat": "{whole} POINT {decimal}",
    "useTeens": true,
    "useCompoundNumbers": true
  },
  "numbers": {
    "ones": [
      "",
      "ONE",
      "TWO",
      "THREE",
      "FOUR",
      "FIVE",
      "SIX",
      "SEVEN",
      "EIGHT",
      "NINE"
    ],
    "tens": [
      "",
      "TEN",
      "TWENTY",
      "THIRTY",
      "FORTY",
      "FIFTY",
      "SIXTY",
      "SEVENTY",
      "EIGHTY",
      "NINETY"
    ],
    "hundreds": [
      "",
      "ONE HUNDRED",
      "TWO HUNDRED",
      "THREE HUNDRED",
      "FOUR HUNDRED",
      "FIVE HUNDRED",
      "SIX HUNDRED",
      "SEVEN HUNDRED",
      "EIGHT HUNDRED",
      "NINE HUNDRED"
    ],
    "scales": ["", "THOUSAND", "MILLION", "BILLION", "TRILLION", "QUADRILLION"]
  },
  "specialNumbers": {
    "teens": [
      "ELEVEN",
      "TWELVE",
      "THIRTEEN",
      "FOURTEEN",
      "FIFTEEN",
      "SIXTEEN",
      "SEVENTEEN",
      "EIGHTEEN",
      "NINETEEN"
    ],
    "compoundSeparator": "-",
    "special": {
      "0": "ZERO"
    }
  }
}

Localization Settings Explained

  • skipOneForThousand: Skip "one" word for thousands (e.g., "bir bin" → "bin")
  • skipOneForHundred: Skip "one" word for hundreds (e.g., "bir yüz" → "yüz")
  • useTeens: Use special words for numbers 11-19
  • useCompoundNumbers: Use compound number format (e.g., "twenty-one" vs "twenty one")
  • compoundSeparator: Separator for compound numbers (e.g., "-" for English)
  • currencyFormat: Format string for currency representation
  • numberFormat: Format string for number-only representation

Project Structure

NumWordify/
├── Converters/
│   └── NumberToWordsConverter.cs    # Core conversion logic
├── Extensions/
│   └── DecimalExtensions.cs         # Extension methods for decimal
├── Models/
│   └── LocalizationModel.cs         # Data models for localization
└── Resources/                       # Language resource files
    ├── en-US.json
    ├── tr-TR.json
    ├── fr-FR.json
    └── es-ES.json

Requirements

  • .NET 9.0 or higher

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. Here are some ways you can contribute:

  • Add support for new languages
  • Improve existing language support
  • Add new features
  • Fix bugs
  • Improve documentation
  • Add tests

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Kadir Emre Parlak

Support

If you encounter any issues or have questions:

  1. Check the GitHub Issues for existing problems or solutions
  2. Create a new issue if your problem is not already reported
  3. For usage questions, provide a minimal code example that demonstrates the issue

Changelog

See CHANGELOG.md for a list of changes in each version.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 104 1/13/2025

See CHANGELOG.md for release notes.