WordPress / WordPress/WordPress-Coding-Standards
Increase the strictness of the translator comment sniff
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 2.8k
- Forks
- 521
- Avg merge
- 5d 20h
- Merged PRs (30d)
- 1
Description
When sniffing for translator comments, the contents of the comment is not taken into consideration. This means that there's no check to ensure the placeholder notation in the comment matches the available placeholders in the localised string.
The reason for this is that such sniffing is potentially error prone. From https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/423#issuecomment-269061587:
I will currently not address checking the number of placeholders against the translators comment as the formats used vary and this would IMHO be extremely prone to bugs. See the below examples to illustrate what I mean:
/* translators: 1. number of monkeys, 2. location. */ /* translators: %1$d: number of monkeys, %2$s: location. */ /* translators: %d - number of monkeys, %s - location. */ /* translators: number of monkeys, location. */ __( 'There are %1$d monkeys in the %2$s', 'my-slug' );
That said, the 41057 project presents an opportunity to standardise on the format used in translator comments, so that their format can be made more strict and therefore be made sniffable for accuracy.
Background: A plugin of mine had a mismatching translator comment (%s vs %d) and was confusing translators.
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 by reviewing the translator comment sniff and the linked WordPress core ticket, then compare the placeholder formats shown in this issue. Done means the agreed translator-comment format is validated against the localized string's placeholders without misclassifying supported formats.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100