unicode-rbnf
raw JSON → 2.4.0 verified Fri May 01 auth: no python
Rule-based number formatting using Unicode CLDR data. Supports plural rules, ordinal rules, and other rule-based number formatting patterns. Current version 2.4.0, compatible with Python >=3.8.0.
pip install unicode-rbnf Common errors
error ModuleNotFoundError: No module named 'rbnf' ↓
cause The package is not installed or installed under a different name.
fix
Run 'pip install unicode-rbnf' and ensure no typing errors.
error AttributeError: module 'rbnf' has no attribute 'RbnfEngine' ↓
cause Trying to access RbnfEngine directly from the module instead of importing it.
fix
Use 'from rbnf import RbnfEngine'.
Warnings
gotcha RbnfEngine.for_language('en-US') may return None if the language data is not installed or incomplete. Always check the result. ↓
fix If None is returned, ensure the language code is correct and that the CLDR data package is installed or loadable.
gotcha Rule set names are case-sensitive and language-specific. 'spellout' is common but not all languages have it. ↓
fix List available rule sets using engine.list_rules() or refer to CLDR documentation.
Imports
- RbnfEngine wrong
import rbnf; rbnf.RbnfEnginecorrectfrom rbnf import RbnfEngine
Quickstart
from rbnf import RbnfEngine
# Create engine for English (US) with default rules
engine = RbnfEngine.for_language('en-US')
# Format a number using the 'spellout' rule set
result = engine.format_number(1234, 'spellout')
print(result) # e.g., 'one thousand two hundred thirty-four'