Closed (works as designed)
Project:
Drupal core
Version:
7.x-dev
Component:
poll.module
Priority:
Minor
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
22 Nov 2010 at 08:34 UTC
Updated:
2 Jan 2011 at 03:12 UTC
Currently, poll.pages.inc and poll.bar.tpl.php call the said function as:
format_plural($node->votes, '1 vote', '@count votes')
In languages using singular for 21, 31 etc., this leads to '21 votes' being displayed as '1 vote'.
I'm not sufficiently familiar with inner workings of format_plural to tell what should be done, but obviously the current situation isn't quite acceptable.
Comments
Comment #1
joachim commentedThis is a problem with format_plural(), not poll.
Moving this to base and 7, though I'm sure there's an existing issue for this already as I remember noticing that languages such as French where 0 is singular will fail too.
Comment #2
Drave Robber commentedThis might indeed rather be a problem with format_plural(), but sorry, this is not directly related to "0 votes" issue. "Zero votes" displays OK in my language (Latvian).
I've been able to hack-fix this by changing
format_plural($node->votes, '1 vote', '@count votes')to
format_plural($node->votes, '@count vote', '@count votes')I'm not sure this would work in an i18n system though.
Of course, generally speaking, problem is with format_plural(), because it's hardly possible to adapt it to all counting systems used on this tiny planet. In Russian, '4 years' = '4 года', but '5 years' = '5 лет'... now how about this? :)
Comment #3
marcingy commentedThe previous issue was this http://drupal.org/node/425434 - which is closed as won't fix so I assume this is the same.
Comment #4
Drave Robber commentedI'm still not sure whether it was correct to move this to base queue; it seems that format_plural(), through locale_get_plural, always calls to $language->formula, so there's no way for it to return wrong value if the 'language formula', itself a tricky entity, is defined correctly.
As I understand this now, format_plural correctly formats 21, 31 etc. as singular in Russian, Latvian and many other languages. However, poll.module follows this bad advice on api.drupal.org page for format_plural:
(emphasis mine)
This is equal to saying "if it returns singular, it will be 1", which is not true.
Hence, I now believe the above advice is wrong and my quick fix in #2 is correct.
Anyway, I'm giving up on this issue as I can always hack two or three lines of code for myself, but have no time to waste fighting for this.
Comment #5
marcingy commentedAh I understand what you are saying now - yes this is an issue with the poll module not format_plural itself. Reopening and I'll try and work on a patch for the problem.
Comment #6
Drave Robber commentedAfter some more digging, I found an issue which already discussed this, and the whole problem seems to be a lot more complex: #384866: Clarify documentation for format_plural()
Comment #7
marcingy commentedOk so the string is correct and the issue is with 'simply' setting up the correct translation rules.