From 89db62d47f88638614c790c0669c4c0cc668a647 Mon Sep 17 00:00:00 2001 From: Kamran Abdul Aziz Date: Wed, 21 Oct 2026 13:28:41 +0530 Subject: [PATCH] Media: Use plural forms for the "Load more" media item count. 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. --- src/js/media/views/attachments/browser.js | 9 ++- tests/qunit/index.html | 1 + .../js/media/test-attachments-browser.js | 63 +++++++++++++++++++ 3 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 tests/qunit/wp-includes/js/media/test-attachments-browser.js diff --git a/src/js/media/views/attachments/browser.js b/src/js/media/views/attachments/browser.js index 8d7d4dca51b76..d464ad6afe18f 100644 --- a/src/js/media/views/attachments/browser.js +++ b/src/js/media/views/attachments/browser.js @@ -5,6 +5,7 @@ var View = wp.media.View, AttachmentsBrowser, infiniteScrolling = wp.media.view.settings.infiniteScrolling, __ = wp.i18n.__, + _n = wp.i18n._n, sprintf = wp.i18n.sprintf; /** @@ -606,9 +607,13 @@ AttachmentsBrowser = View.extend(/** @lends wp.media.view.AttachmentsBrowser.pro if ( this.collection.length ) { this.loadMoreCount.$el.text( - /* translators: 1: Number of displayed attachments, 2: Number of total attachments. */ sprintf( - __( 'Showing %1$s of %2$s media items' ), + /* translators: 1: Number of displayed attachments, 2: Number of total attachments. */ + _n( + 'Showing %1$s of %2$s media item', + 'Showing %1$s of %2$s media items', + this.collection.getTotalAttachments() + ), this.collection.length, this.collection.getTotalAttachments() ) diff --git a/tests/qunit/index.html b/tests/qunit/index.html index f9033a776151c..55e4bd4dabe2d 100644 --- a/tests/qunit/index.html +++ b/tests/qunit/index.html @@ -205,6 +205,7 @@ +