WordPress / WordPress/theme-check
[Function _n] What wrong?
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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