icu4py documentation¶
Python bindings to the ICU (International Components for Unicode) library (ICU4C).
Let’s you do cool locale-aware things with text, like split it into sentences with SentenceBreaker:
Split text into sentences with SentenceBreaker:
>>> from icu4py.breakers import SentenceBreaker
>>> text = 'You asked "Why?". We answered "Why not?"'
>>> breaker = SentenceBreaker(text, "en_GB@ss=standard")
>>> list(breaker)
['You asked "Why?". ', 'We answered "Why not?"']
…or format messages with variable pluralization using MessageFormat:
>>> from icu4py.messageformat import MessageFormat
>>> pattern = "{count,plural,one {# file} other {# files}}"
>>> fmt = MessageFormat(pattern, "en_GB")
>>> fmt.format({"count": 1})
'1 file'
>>> fmt.format({"count": 5})
'5 files'
Get started by following the installation instructions, and explore the API reference for more details.
Contents: