Opened 5 years ago

Closed 5 years ago

#5606 closed defect (bug) (fixed)

i18n formatting breaks dashboard count

Reported by: sarekofvulcan Owned by: ryan
Priority: normal Milestone: 2.5
Component: Administration Version: 2.5
Severity: normal Keywords: has-patch needs-testing
Cc:

Description (last modified by lloydbudd)

I have 1812 posts in my blog, but my dashboard is reporting that I have "1 posts". I added the following code to wp-admin/index.php immediately after the $num_posts line:

echo $num_posts;
echo ngettext( '%d post', '%d posts', $num_posts);
echo number_format_i18n($num_posts);
echo sprintf('%d posts', '1,812');

The answers were:
1812
%d posts
1,812
1 posts

So, it appears that that comma makes sprintf unhappy.

Attachments (1)

index.diff (2.1 KB) - added by sarekofvulcan 5 years ago.
wp-admin/index.php patch -- %d => %s

Download all attachments as: .zip

Change History (12)

Well, there were line breaks in there before... Just for clarity, that's

{{{echo $num_posts;
echo ngettext( '%d post', '%d posts', $num_posts);
echo number_format_i18n($num_posts);
echo sprintf('%d posts', '1,812');}}}

and

{{{1812
%d posts
1,812
1 posts}}}

*headdesk* You get the idea, right?

  • Description modified (diff)

Thanks, lloydbudd.

I'm attaching a diff: it fixes the post count, but none of my other counts are high enough to properly test the others.

wp-admin/index.php patch -- %d => %s

  • Keywords has-patch added
  • Keywords needs-testing added

comment:7 follow-up: ↓ 8   nbachiyski5 years ago

The patch forks for me, I have a sample install with lots of 'em.

comment:8 in reply to: ↑ 7   sarekofvulcan5 years ago

Replying to nbachiyski:

The patch forks for me, I have a sample install with lots of 'em.

*is confused* Is that a typo for "works"?

Yes, I meant works.

  • Owner changed from anonymous to ryan
  • Resolution set to fixed
  • Status changed from new to closed

Already fixed.

Note: See TracTickets for help on using tickets.