Opened 14 years ago
Last modified 12 days ago
#15156 new New feature
Ordinal numbers in English and in other locales
Reported by: | 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 , 14 years ago
Component: | Uncategorized → Translations |
---|
comment:2 by , 14 years ago
comment:3 by , 14 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
Marking this DDN. Like claudep, I'm not convinced this is even possible, but i18n isn't my specialty.
comment:4 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:5 by , 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 , 12 years ago
Triage Stage: | Design decision needed → Accepted |
---|
I agree with aausgustin's idea of using pgettext. It's better than nothing.
comment:7 by , 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 :-/
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.
comment:8 by , 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 , 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.
comment:10 by , 12 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:11 by , 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 , 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 , 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 , 11 years ago
Owner: | removed |
---|---|
Status: | assigned → new |
Sorry, but I didn't find and probably won't find the time this ticket requires. I've therefor deasigned it.
comment:15 by , 10 years ago
Component: | Translations → Internationalization |
---|---|
Version: | 1.2 → master |
comment:16 by , 8 months ago
Cc: | added |
---|
comment:17 by , 12 days ago
Cc: | added |
---|
comment:18 by , 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.
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).