WordPress / WordPress/theme-check

[Function _n] What wrong?

Open
#175 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
371
Forks
113
Avg merge
8m
Merged PRs (30d)
5

Description

This code of Woocommerce Plugin:

echo apply_filters( 'woocommerce_available_download_count', '<span class="woocommerce-Count count">' . sprintf( _n( '%s download remaining', '%s downloads remaining', $download['downloads_remaining'], 'domain' ), $download['downloads_remaining'] ) . '</span> ', $download );

but Them check is warning:

WARNING: Found a translation function that has an incorrect number of arguments. Function _n, with the arguments '%s download remaining', '%s downloads remaining', downloads_remaining, 'domain'

I see code here:

https://developer.wordpress.org/reference/functions/_n/

And my text domain is domain:

Warning: More than one text-domain is being used in this theme. This means the theme will not be compatible with WordPress.org language packs.
The domains found are domain, downloads_remaining

I only found downloads_remaining in echo apply_filters( 'woocommerce_available_download_count', '<span class="woocommerce-Count count">' . sprintf( _n( '%s download remaining', '%s downloads remaining', $download['downloads_remaining'], 'domain' ), $download['downloads_remaining'] ) . '</span> ', $download );

What wrong?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided _n() call and the Theme Check translation warning, then inspect how the checker counts _n() arguments and identifies text domains. Reproduce the warning with the WooCommerce snippet and compare it with the WordPress _n() reference; done means the checker reports only an actual text domain and no longer treats downloads_remaining as one.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, wordpress
Domain
internationalization, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.