Description

Some of the strings on contrib-humanize.po could be not used for Albanian locale (sq). I suppose other locales have the same issue with the way English build ordinal numbers using th, st, nd and rd (as in 4th, 15th, 2nd, etc). To make things even more complicated, there is gender to be considered here. As an example, the word used for "month" and the one used for "week" have different gender in Albanian.

Oldest firstNewest firstThreaded

Show commentsShow property changes

Change History (15)

The ordinal template tag of contrib.humanize is not fully localizable in several languages, indeed. But I think this is an unresolvable issue. There are just too many different cases to consider as the algorithm may be different for each language. I suggest to look at the code and implement it for your own specific needs (languages).

Swedish: Here every number that ends with a 1 or 2 has to suffixed with ":a" instead of ":e"

Russian

Catalan

Galician, Italian, Portuguese, and Spanish: The suffix depends on the gender of the noun to be counted

That being said, the list on Wikipedia looks very incomplete, but if the information about very widely uses languages like Spanish is correct here, the context would have to include the whole number, which looks rather impractical to me :-/

Since the gender could be indicated by the context it is not as problematic as the irregular suffix/prefix in languages like Russian and Catalan.

Yes, I was thinking along the same line. formats.py is probably the best place for this too. At first I thought that may be localflavor would be better, but since that is based around countries and not languages, formats.py sounds to me like the ideal place.

One issue I see there so far is how to deal with setups where USE_L10N is disabled. Should in this case a fallback implementation be just used from locales.en.formats or should this be integrated in the global_settings module? IMO the first one makes more sense since this would be the one and only callable in the whole settings module right now which would break the style there.

Something else I'd like to get in there is having the system still be based around messages in order to allow users to get their custom "context" (referencing the noun the ordinal is intended for) into the message. This way languages like Spanish that don't have a gender-neutral ordinal-indicator could detect the necessary gender from something like {{ num|ordinal:"email" }}.

I don't know if the ordinal would always reference the same noun in a sentence independent of the language but it should get around at least some of the edge cases.