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

joachim’s picture

Version: 6.19 » 7.x-dev
Component: poll.module » base system

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

Drave Robber’s picture

This 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? :)

marcingy’s picture

Status: Active » Closed (won't fix)

The previous issue was this http://drupal.org/node/425434 - which is closed as won't fix so I assume this is the same.

Drave Robber’s picture

The previous issue was this http://drupal.org/node/425434 - which is closed as won't fix so I assume this is the same.

  • That issue is closed as 'fixed', not as 'won't fix'.
  • This is not 'the same' as this is about treatment of 21, 31 etc., not about treatment of 0.

I'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:

$singular The string for the singular case. Please make sure it is clear this is singular, to ease translation (e.g. use "1 new comment" instead of "1 new"). Do not use @count in the singular string.

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

marcingy’s picture

Component: base system » poll.module
Status: Closed (won't fix) » Active

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

Drave Robber’s picture

After 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()

marcingy’s picture

Status: Active » Closed (works as designed)

Ok so the string is correct and the issue is with 'simply' setting up the correct translation rules.