spellOrdinal static method
Spells out the ordinal form of number in English (first, second, third).
Implementation
static String spellOrdinal(int number) {
final spelled = spell(number);
final words = spelled.split(RegExp(r'[\s-]'));
final last = words.last;
String ordinalLast;
if (_ordinalIrregular.containsKey(last)) {
ordinalLast = _ordinalIrregular[last]!;
} else if (last.endsWith('y')) {
ordinalLast = '${last.substring(0, last.length - 1)}ieth';
} else {
ordinalLast = '${last}th';
}
return spelled.substring(0, spelled.length - last.length) + ordinalLast;
}