WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 5 years ago

#3663 closed defect (bug) (fixed)

ngettext dislikes formatted numbers

Reported by: nbachiyski Owned by: markjaquith
Milestone: 2.2 Priority: normal
Severity: normal Version: 2.1
Component: Administration Keywords: dashboard error ngettext
Focuses: Cc:

Description

What happens:
If the number of comments, posts or cats in the Dashboard is greater than a thousand and the current locale has defined different from default plural rules the <code>ngettext</code>

function spits an error.

Why:
The aforementioned numbers are passed through <code>number_format</code> before usage, which adds a coma between digits groups. Thus the number is no more the valid number, <code>ngettext</code> expects.

Solution:
Could we sacrifice the formatting of the numbers? If we could the patch below is relevant.

Attachments (2)

gettext-dislikes-formats.diff (872 bytes) - added by nbachiyski 7 years ago.
number_format02.diff (2.4 KB) - added by markjaquith 7 years ago.
Patch for trunk

Download all attachments as: .zip

Change History (9)

markjaquith7 years ago

Patch for trunk

comment:1 follow-up: markjaquith7 years ago

  • Owner changed from anonymous to markjaquith
  • Status changed from new to assigned

Why can't we pass non-number_format()'d version to ngettext and then use the number_format()'d version in the sprintf() ? See patch.

Also... shouldn't we provide a function like ___number_format() so that translators can provide for a locale's number formatting? For instance, in India they format numbers differently. (open a separate ticket if you agree)

comment:2 in reply to: ↑ 1 nbachiyski7 years ago

Replying to markjaquith:

Why can't we pass non-number_format()'d version to ngettext and then use the number_format()'d version in the sprintf() ? See patch.

Also... shouldn't we provide a function like ___number_format() so that translators can provide for a locale's number formatting? For instance, in India they format numbers differently. (open a separate ticket if you agree)

That is why I wanted to remove the formatting. It will be a little burden for translators to dig into number_format options. On the other side it would be nice to have formatted numbers. If you say so, we will arange the things for translators :-)

comment:3 markjaquith7 years ago

Well, lets fix the bug first (the sending of formatted numbers to ngettext()) and I'll open a ticket to explore i18n of number formatting.

comment:4 markjaquith7 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [4808]) Do not pass comma-formatted numbers to ngettext(). Props nbachiyski. fixes #3663

comment:5 markjaquith7 years ago

#3677 is the ticket for i18n of number_format()

comment:6 dtc7 years ago

  • Keywords dashboard error ngettext added; has-patch removed
  • Resolution fixed deleted
  • Status changed from closed to reopened
  • Version changed from 2.1 to 2.1.2

Bug reintroduced in WP 2.1.2.

comment:7 markjaquith7 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed
  • Version changed from 2.1.2 to 2.1

Bug was fixed in trunk only, so the fix won't show up in a release version until 2.2 is released in April.

Note: See TracTickets for help on using tickets.