Number To Word (FieldFormatter)
This module provides a field formatter to display numeric field values as words, supporting integers, decimals, and floats in multiple languages. It offers configuration options for prefixes, suffixes, capitalization, and decimal separators, making it useful for various display needs like currency or accessibility.
Number to Word
Description:
Provides a field formatter that converts numeric field values into their word representation. Works with integer, decimal, and float fields using the Composer-based kwn/number-to-words library.
Key Features
- Converts numeric values to words automatically on display
- Supports integer, decimal, and float fields
- Multiple language/locales supported (30+)
- Prefix and suffix text for contextual display
- Optional thousand separator for English numbers
- Decimal separator word (e.g., "point", "and")
- Option to capitalize the first letter of the output
- Fully compatible with Drupal 11 and PHP 8.4
Use Cases
- Displaying currency amounts in words (invoices, checks)
- Accessibility improvements for screen readers
- Educational content or numeric exercises
- Legal or formal document generation
Installation
Via Composer (Drupal.org release):
composer require drupal/numbertoword drush en numbertoword
Manual / Local Development:
- Place module in
web/modules/custom/numbertoword - Install dependency:
composer require kwn/number-to-words - Enable module:
drush en numbertoword
Configuration
- Navigate to Structure → Content types → [Your Content Type] → Manage Display
- Select your numeric field and set numbertoWord as the formatter
- Click the gear icon to configure settings:
Click Update then Save
Usage
Once configured, numeric fields will display numbers as words automatically.
Input Settings Output 12345 default twelve thousand three hundred forty-five 12345.67 decimal separator: "point" twelve thousand three hundred forty-five point six seven 1500 Prefix: "USD", Suffix: "only" USD one thousand five hundred only 42 Capitalize first letter: yes Forty-two 1234567 Thousand separator: comma one million, two hundred thirty-four thousand, five hundred sixty-sevenLanguages supported: English, Albanian, Arabic, Azerbaijani, Bulgarian, Czech, Danish, Dutch, Estonian, French, German, Georgian, Hungarian, Indonesian, Italian, Latvian, Lithuanian, Malay, Persian, Polish, Portuguese (Brazil), Romanian, Russian, Slovak, Spanish, Swedish, Turkish, Turkmen, Ukrainian, Yoruba
Troubleshooting
- Formatter doesn’t appear: Ensure module is enabled and cache cleared (
drush cr) - NumberToWords library not found: Run
composer require kwn/number-to-words - Decimal numbers incorrect: Check decimal separator word and ensure numeric input
- Language fallback: If selected language fails, English will be used