+sub get_ordinal {
+ my ($num, $locale) = @_;
+ my $translation = $translation_mapping{$locale} // 'en';
+
+ if ($translation eq 'no') {
+ return $num . ".";
+ } elsif ($translation eq 'en') {
+ # http://en.wikipedia.org/wiki/English_numerals#Ordinal_numbers
+ my $units = $num % 10;
+ my $tens = (($num - $units) / 10) % 10;
+ if ($tens == 1) {
+ return $num . "th";
+ } elsif ($units == 1) {
+ return $num . "st";
+ } elsif ($units == 2) {
+ return $num . "nd";
+ } elsif ($units == 3) {
+ return $num . "rd";
+ } else {
+ return $num . "th";
+ }
+ } else {
+ die "Missing ordinal strategy for locale $locale";
+ }
+}
+