Skip to content

fix(i18n): resolve translation warnings in make-pot#4323

Open
faisalahammad wants to merge 2 commits into
10up:developfrom
faisalahammad:fix/4313-translation-warnings
Open

fix(i18n): resolve translation warnings in make-pot#4323
faisalahammad wants to merge 2 commits into
10up:developfrom
faisalahammad:fix/4313-translation-warnings

Conversation

@faisalahammad

@faisalahammad faisalahammad commented Jun 19, 2026

Copy link
Copy Markdown

Summary

Running wp i18n make-pot produced two warnings in the JS files: one duplicate translator comment on the string %1$s and %2$s and one missing translator comment on Page %d. This change unifies the comments and adds the missing ones so the POT file builds cleanly.

Fixes #4313

Changes

assets/js/features/components/control.js

Before:

/* translators: %1$s: first feature name, %2$s: second feature name */
__('%1$s and %2$s', 'elasticpress'),
// ...
/* translators: %1$s: comma-separated list of feature names, %2$s: last feature name */
__('%1$s and %2$s', 'elasticpress'),

After:

/* translators: %1$s: feature name(s), %2$s: last feature name */
__('%1$s and %2$s', 'elasticpress'),
// ...
/* translators: %1$s: feature name(s), %2$s: last feature name */
__('%1$s and %2$s', 'elasticpress'),

Why: The same string literal had two different translator comments, which triggers a make-pot warning. A single comment describing both placeholders works for both call sites.

assets/js/instant-results/components/results/pagination.js

Before:

aria-label={sprintf(__('Page %d', 'elasticpress'), page.value)}

After:

/* translators: %d: Page number. */
aria-label={sprintf(__('Page %d', 'elasticpress'), page.value)}

Why: %d needs a translator comment to explain it is the page number.

assets/js/synonyms/apps/synonyms-settings.js

Before:

/* translators: Synonyms count */
sprintf(__('Synonyms (%d)', 'elasticpress'), synonyms.length)

After:

/* translators: %d: Number of synonyms. */
sprintf(__('Synonyms (%d)', 'elasticpress'), synonyms.length)

Why: The %d placeholder is clearer for translators when the comment references it directly. Same change applied to hyponyms and replacements tabs.

Testing

Test 1: Generate POT file

  1. Go to the plugin folder.
  2. Run wp i18n make-pot . lang/elasticpress.pot.

Result: No warnings. POT file builds successfully.

Screenshots

Before:
SCR-20260619-ttck

After:
image

- Unify translator comments for %1 and %2 in feature control.js
- Add translator comment for Page %d in pagination.js
- Improve translator comments for %d placeholders in synonyms settings

Fixes 10up#4313
Comment thread assets/js/features/components/control.js Outdated
Comment thread assets/js/features/components/control.js
Replace __() with _x() to resolve make-pot duplicate comment warning.
Same translator comment on both calls, distinct disambiguation contexts
for the two call sites.

Addresses PR review feedback.

Refs 10up#4323
@faisalahammad

Copy link
Copy Markdown
Author

@burhandodhy Addressed both review threads:

  • Replaced __() with _x() using context 'two feature names' and 'multiple feature names' for disambiguation
  • Same translator comment on both calls to avoid make-pot duplicate warning
  • npm run lint-js passes clean
  • wp i18n make-pot produces no warnings
  • CodeRabbit passed

Ready for re-review.

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.

BUG: Fix translation warnings

2 participants