Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for more mistakes in translatable strings #64

Merged
merged 12 commits into from
Aug 6, 2018
Merged

Conversation

swissspidy
Copy link
Member

See #61.

@swissspidy swissspidy changed the title [WIP] Check for more mistakes in translatable strings Check for more mistakes in translatable strings Aug 3, 2018
@swissspidy swissspidy requested a review from a team August 3, 2018 14:45
@swissspidy swissspidy requested a review from schlessera August 5, 2018 15:47
*/

sprintf(
_n( '%1$s Comment (%2$s)', '%2$$s Comments (%1$s)', $number, 'foo-plugin' ),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double dollar sign here: %2$$s

$plural_placeholders = $plural_placeholders[0];

// see https://developer.wordpress.org/plugins/internationalization/how-to-internationalize-your-plugin/#plurals
if ( count( $single_placeholders ) < \count( $plural_placeholders ) ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two different forms of count() used, one relative and one absolute.

$location
) );
} else {
sort( $single_placeholders );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm probably missing something here, but I think it warrants a comment. The goal here is to verify the ordering of the placeholders. However, before comparing them, you sort them here. Would that put them into the same order no matter what?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what I was thinking here. I copied this from WPCS, but somehow messed it up. The order should be irrelevant, but different placeholders are usually not ok.

@swissspidy swissspidy requested a review from schlessera August 5, 2018 17:56
@swissspidy
Copy link
Member Author

I think this one is good to go (pending passing tests and final review).

Nice side effect when this is in master:

I can use #69 to create a WordPress Trac ticket to improve all the strings in WordPress core that get flagged by this command.

@schlessera schlessera added this to the 0.1.0 milestone Aug 6, 2018
@schlessera schlessera merged commit 7762b19 into master Aug 6, 2018
@schlessera schlessera deleted the 61-audit branch August 6, 2018 17:41
schlessera added a commit that referenced this pull request Jan 6, 2022
Check for more mistakes in translatable strings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants