Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spell out ordinal numbers

There are few ways to generate short ordinal numbers like "1st", "2nd", etc, with NSNumberFormatter (from iOS 9) or 3rd parties like FormatterKit.

There is also a way to spell out cardinal numbers with NSNumberFormatter that gives one, two, three.

However, I need to get the unabbreviated spelling - first, second, third.

I know that iOS internally can do it, because if I pass "1st" to AVSpeechUtterance it pronounces it as "first". I was wondering if there is any API to get a string with spelling of ordinal numbers, preferably, for multiple languages?

like image 624
Dmitry Avatar asked Oct 29 '22 13:10

Dmitry


1 Answers

I couldn't find an existing libraries for that, so I created my own.

It uses ICU4C underneath from the system libraries. Before using, please check how the example project works:

https://github.com/dimat/DMNumberSpellOutFormatter

like image 106
Dmitry Avatar answered Nov 15 '22 05:11

Dmitry