Opened 14 years ago

Last modified 12 days ago

#15156 new New feature

Ordinal numbers in English and in other locales

Reported by: Besnik <besnik@…> Owned by:
Component: Internationalization Version: dev
Severity: Normal Keywords:
Cc: Ülgen Sarıkavak, Maciej Olko Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

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.

Change History (18)

comment:1 by Besnik <besnik@…>, 14 years ago

Component: UncategorizedTranslations

comment:2 by Claude Paroz, 14 years ago

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).

This reminds me about a similar discussion in the GNOME Nautilus File Manager (see e.g. https://bugzilla.gnome.org/show_bug.cgi?id=325284 and http://git.gnome.org/browse/nautilus/tree/libnautilus-private/nautilus-file-operations.c#n440).

comment:3 by Russell Keith-Magee, 14 years ago

Triage Stage: UnreviewedDesign decision needed

Marking this DDN. Like claudep, I'm not convinced this is even possible, but i18n isn't my specialty.

comment:4 by Łukasz Rekucki, 14 years ago

Severity: Normal
Type: New feature

comment:5 by Aymeric Augustin, 13 years ago

Easy pickings: unset
UI/UX: unset

We might improve things slightly by using pgettext_lazy instead of ugettext_lazy.

That would make it possible to distinguish the 'th' for 0 from the 'th' for 5 in this list:

suffixes = (_('th'), _('st'), _('nd'), _('rd'), _('th'), _('th'), _('th'), _('th'), _('th'), _('th'))

Would this be useful? If it isn't, then I think we should just close this as "wontfix".

Handling gender in the ordinal filter is another topic, I suggest opening another ticket for this feature if you deem it useful.

comment:6 by Jannis Leidel, 12 years ago

Triage Stage: Design decision neededAccepted

I agree with aausgustin's idea of using pgettext. It's better than nothing.

comment:7 by Horst Gutmann, 12 years ago

Given the severe differences between how different languages "count" wouldn't that in the worst case require the context to actually include the number itself?

I skimmed a little bit through http://en.wikipedia.org/wiki/Ordinal_indicator and some pages about the Japanese and Chinese languages going with at worst 1-10+above should be enough except for following exceptions:

  • 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 :-/

Version 0, edited 12 years ago by Horst Gutmann (next)

comment:8 by Claude Paroz, 12 years ago

I'm not suprised at all by your findings. I maintain my original opinion: the rules are too much diverse to be able to solve this by mere translation.

comment:9 by Aymeric Augustin, 12 years ago

Yeah, the fix proposed here is "better than nothing, fixes it for a few languages". It's by no means a definitive solution.

Last edited 12 years ago by Aymeric Augustin (previous) (diff)

comment:10 by Horst Gutmann, 12 years ago

Owner: changed from nobody to Horst Gutmann
Status: newassigned

comment:11 by Claude Paroz, 11 years ago

Proposal: Allow defining a def ordinal(value): function in conf/locale/<lang>/formats.py. We could then generate the ordinal string by calling get_format('ordinal')(value).

comment:12 by Horst Gutmann, 11 years ago

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.

I will try to come up with an implementation in the next week or so.

Sorry for the delay on this.

comment:13 by Horst Gutmann, 11 years ago

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.

@Besnik Would this help in your situation?

comment:14 by Horst Gutmann, 11 years ago

Owner: Horst Gutmann removed
Status: assignednew

Sorry, but I didn't find and probably won't find the time this ticket requires. I've therefor deasigned it.

comment:15 by Tim Graham, 10 years ago

Component: TranslationsInternationalization
Version: 1.2master

comment:16 by Ülgen Sarıkavak, 8 months ago

Cc: Ülgen Sarıkavak added

comment:17 by Maciej Olko, 12 days ago

Cc: Maciej Olko added

comment:18 by Maciej Olko, 12 days ago

The situation discussed here was improved in #28877 – now prefixes in ordinal numbers are allowed, which fixes Chinese translation. Gender wasn't in scope.

Note: See TracTickets for help on using tickets.
Back to Top