Skip to main content

Unicode RBNF

A pure Python implementation of rule based number formatting (RBNF) using the Unicode Common Locale Data Repository (CLDR).

This lets you spell out numbers for a large number of locales:

from unicode_rbnf import RbnfEngine

engine = RbnfEngine.for_language("en")
assert engine.format_number(1234).text == "one thousand two hundred thirty-four"

Different formatting purposes are supported as well, depending on the locale:

from unicode_rbnf import RbnfEngine, FormatPurpose

engine = RbnfEngine.for_language("en")
assert engine.format_number(1999, FormatPurpose.CARDINAL).text == "one thousand nine hundred ninety-nine"
assert engine.format_number(1999, FormatPurpose.YEAR).text == "nineteen ninety-nine"
assert engine.format_number(11, FormatPurpose.ORDINAL).text == "eleventh"

For locales with multiple genders, cases, etc., the different texts are accessible in the result of format_number:

from unicode_rbnf import RbnfEngine

engine = RbnfEngine.for_language("de")
print(engine.format_number(1))

Result:

FormatResult(
  text='eins',
  text_by_ruleset={
    'spellout-numbering': 'eins',
    'spellout-cardinal-neuter': 'ein',
    'spellout-cardinal-masculine': 'ein',
    'spellout-cardinal-feminine': 'eine',
    'spellout-cardinal-n': 'einen',
    'spellout-cardinal-r': 'einer',
    'spellout-cardinal-s': 'eines',
    'spellout-cardinal-m': 'einem'
  }
)

The text property of the result holds the text of the ruleset with the shortest name (least specific).

Supported locales

See: https://github.com/unicode-org/cldr/tree/release-44/common/rbnf

Engine implementation

Not all features of the RBNF engine are implemented. The following features are available:

  • Literal text (hundred)
  • Quotient substitution (<< or ←←)
  • Reminder substitution (>> or →→)
  • Optional substitution ([...])
  • Rule substituton (←%ruleset_name←)
  • Rule replacement (=%ruleset_name=)
  • Special rules:
    • Negative numbers (-x)
    • Improper fractions (x.x)
    • Not a number (NaN)
    • Infinity (Inf)

Some features that will need to be added eventually:

  • Proper fraction rules (0.x)
  • Preceding reminder substitution (>>> or →→→)
  • Number format strings (==)
  • Decimal format patterns (#,##0.00)
  • Plural replacements ($(ordinal,one{st}...))

Metadata

Release files for unicode-rbnf 2.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for unicode-rbnf 2.5.0
File Size Uploaded Provenance Actions
unicode_rbnf-2.5.0.tar.gz 104.6 kB With provenance Details for unicode_rbnf-2.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for unicode-rbnf 2.5.0
File Interpreter ABI Platform Actions
unicode_rbnf-2.5.0-py3-none-any.whl Python 3 none any Details for unicode_rbnf-2.5.0-py3-none-any.whl

Total release size: 256.6 kB

Release files / unicode_rbnf-2.5.0.tar.gz

Download URL unicode_rbnf-2.5.0.tar.gz
Size 104.6 kB
Tags Source
SHA-256 checksum
How to use checksums
6d26be8ae476f6d30ab915826def56619bfefe29866ca3ed850b2149b93b038f
BLAKE2b-256 checksum
How to use checksums
cf82d32c0cafe3c8bf36c7f7404aba923acce9b2e6fd7c8bdc939b25bea297a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Release files / unicode_rbnf-2.5.0-py3-none-any.whl

Download URL unicode_rbnf-2.5.0-py3-none-any.whl
Size 152.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
77c124841ac4f091611de4f80e1c74795b8e3597c025c5b375af9bcc4b1e94d7
BLAKE2b-256 checksum
How to use checksums
0e857c2a480891f8212d1af8676dac318b289c7d4e3b6e3d6c75b3a5de42bf35
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Security for unicode-rbnf 2.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for unicode_rbnf-2.5.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page