python-babel / babel

The official repository for Babel, the Python Internationalization Library
http://babel.pocoo.org/
BSD 3-Clause "New" or "Revised" License
1.3k stars 433 forks source link

Format ordinal numbers #901

Open septatrix opened 1 year ago

septatrix commented 1 year ago

Often one wants to generate a list of things with ordinals in front of them. E.g. "1st place: Foo, 2nd place: Bar" or "1st choice: Hello, 2nd choice: World". The way these ordinals are represented differs between languages. In e.g. german this would commonly be written as "1. place: Foo, 2. place: Bar".

PyBabel should support these use cases with a respective formatter. Rules how this works can probably be taken from the ICU library.

czepiec commented 1 year ago

Ordinal numbers are usable in some locales even for dates, e.g. "18th September, 2022", which would be very nice (using Pattern Syntax).