Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

icu_rbnf-0.1.0-cp39-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (12.7 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

icu_rbnf-0.1.0-cp39-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (12.6 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

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

File hashes

Hashes for icu_rbnf-0.1.0-cp39-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 462399872bca64a410d34c8aabeff33a401ffe740d736025fc709dc1d52367c1
MD5 d473acecc5552ae89e828108beee5d3e
BLAKE2b-256 d2e82c2570988d70b9a2ac484c81bdc9aea81b710b72a21d1fe21e2e00fb0dda

See more details on using hashes here.

File details

Details for the file icu_rbnf-0.1.0-cp39-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for icu_rbnf-0.1.0-cp39-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 14e22f253972ddc0cc3f2eeeaa5768ee7b37eff510034eb97bf46e89c54d7162
MD5 f964598baeca6f1be94cbfda7d980861
BLAKE2b-256 df9cfc173e23b929f6bf8f1fe91efc733120ee59ddacbe3b227b4a894f0346d8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page