pyicumessageformat
raw JSON → 1.0.0 verified Fri May 01 auth: no python
An unopinionated parser for ICU MessageFormat strings, currently at version 1.0.0. It parses ICU MessageFormat (used for internationalization) into an AST, allowing manipulation, analysis or transformation. The library is stable but maintenance-only with no active development.
pip install pyicumessageformat Common errors
error ModuleNotFoundError: No module named 'pyicumessageformat' ↓
cause Package not installed or installed in a different environment.
fix
Run 'pip install pyicumessageformat' in the correct Python environment.
error AttributeError: module 'pyicumessageformat' has no attribute 'parse' ↓
cause Import error due to wrong casing or typo.
fix
Use 'from pyicumessageformat import parse' exactly.
Warnings
gotcha The library only parses; it does NOT format or resolve messages. Use a library like icu (PyICU) or babel to actually substitute variables. ↓
fix Combine with a formatter, e.g., using pyicu (PyICU) or icu4c.
gotcha Parsing incomplete or malformed ICU patterns may raise exceptions; validation is minimal. ↓
fix Wrap parse() in try/except and handle parse errors gracefully.
Imports
- parse
from pyicumessageformat import parse
Quickstart
from pyicumessageformat import parse
message = "Hello, {name}! You have {count, plural, one {# message} other {# messages}}."
tree = parse(message)
print(tree)
# Output: MessageFormatNode(...)