Skip to content

Media: Use plural forms for the "Load more" media item count - #14620

Open
ekamran wants to merge 1 commit into
WordPress:trunkfrom
ekamran:shifteq/media-showing-count-plural
Open

ekamran wants to merge 1 commit into
WordPress:trunkfrom
ekamran:shifteq/media-showing-count-plural

Conversation

@ekamran

@ekamran ekamran commented Oct 21, 2026

Copy link
Copy Markdown

The "Load more" count in the Media Library showed __( 'Showing %1$s of %2$s media items' ). The English string is always plural, so a library with one media item showed "Showing 1 of 1 media items", and translators had a single form for every count. Its translators comment sat above sprintf() instead of the translation call, so make-pot did not extract it.

This uses _n(), with the plural form following the total, and moves the comment directly above the _n() call. make-pot now extracts the comment and both forms, from browser.js and from the built wp-includes/js/media-views.js. Existing translations of the old string do not carry over to the new pair.

Adds a QUnit test (test-attachments-browser.js) that runs updateLoadMoreView() for one of one and one of two media items and checks the text. It fails on trunk and passes with the change. The suite wraps each test in fake timers, but updateLoadMoreView() is an underscore debounce that measures its wait with the real Date.now(), so the test switches to real timers, cancels any pending call and runs one update at a time.

Tested in a browser on WordPress 7.1.3, whose updateLoadMoreView() is identical to trunk, with infinite scrolling turned off in the user profile (the count only shows then): one media item now shows "Showing 1 of 1 media item", two show "Showing 2 of 2 media items".

Trac ticket: https://core.trac.wordpress.org/ticket/66357

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code and Codex
Used for: Investigation, implementation, QUnit test, browser verification, and PR wording. I reviewed the reasoning and test results, and I take responsibility for the contribution.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

The "Load more" count used `__( 'Showing %1$s of %2$s media items' )`,
which reads "Showing 1 of 1 media items" for a single media item and
gives translators no plural forms. Its translators comment was above
`sprintf()`, so it was not extracted. Use `_n()` with the plural form
following the total, and move the comment above the `_n()` call.

Adds a QUnit test for the count text.

See #66357.
@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props ekamran.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant