Spell out numbers into words using ICU RBNF
Project description
icu_rbnf
A Python library for spelling out numbers into words using ICU's Rule-Based Number Format (RBNF).
Installation
pip install icu_rbnf
Usage
import icu_rbnf
# Spell out numbers in words
icu_rbnf.spellout(123, "en_US") # "one hundred twenty-three"
icu_rbnf.spellout(123.7, "en_US") # "one hundred twenty-three point seven"
icu_rbnf.spellout(123, "fr_FR") # "cent vingt-trois"
# Get ordinal form (e.g., "1st", "2nd")
icu_rbnf.ordinal(21, "en_US") # "21st"
# Get word-based ordinal (e.g., "first", "twenty-first")
icu_rbnf.spellout_ordinal(21, "en_US") # "twenty-first"
# Check if a locale is supported
icu_rbnf.is_locale_supported("en_US") # True
API
spellout(number: int | float, locale: str) -> str
Spell out a number into words for the given locale. Supports both integers and floats.
ordinal(number: int | float, locale: str) -> str
Get the ordinal form of a number for the given locale (e.g., "1st", "2nd"). Floats are truncated to integers.
spellout_ordinal(number: int | float, locale: str) -> str
Spell out ordinal form of a number for the given locale (e.g., "first", "twenty-first"). Floats are truncated to integers. Note: Not all locales support word-based ordinals; some may fall back to numeric format.
is_locale_supported(locale: str) -> bool
Check if a locale is supported by ICU RBNF.
error
Exception class raised when ICU RBNF operations fail.
Requirements
- Python 3.9+
- ICU library (dynamically linked, no separate installation required)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file icu_rbnf-0.1.0-cp39-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: icu_rbnf-0.1.0-cp39-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 12.7 MB
- Tags: CPython 3.9+, manylinux: glibc 2.24+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
462399872bca64a410d34c8aabeff33a401ffe740d736025fc709dc1d52367c1
|
|
| MD5 |
d473acecc5552ae89e828108beee5d3e
|
|
| BLAKE2b-256 |
d2e82c2570988d70b9a2ac484c81bdc9aea81b710b72a21d1fe21e2e00fb0dda
|
File details
Details for the file icu_rbnf-0.1.0-cp39-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: icu_rbnf-0.1.0-cp39-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 12.6 MB
- Tags: CPython 3.9+, manylinux: glibc 2.24+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
14e22f253972ddc0cc3f2eeeaa5768ee7b37eff510034eb97bf46e89c54d7162
|
|
| MD5 |
f964598baeca6f1be94cbfda7d980861
|
|
| BLAKE2b-256 |
df9cfc173e23b929f6bf8f1fe91efc733120ee59ddacbe3b227b4a894f0346d8
|