-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Closed
Labels
Internationalization (i18n)Issues or PRs related to internationalization effortsIssues or PRs related to internationalization efforts[Status] In ProgressTracking issues with work in progressTracking issues with work in progress[Tool] ESLint plugin/packages/eslint-plugin/packages/eslint-plugin[Type] EnhancementA suggestion for improvement.A suggestion for improvement.
Description
What problem does this address?
Right now, the i18n-translator-comments
ESLint rule in eslint-plugin
only checks whether a translatable string with placeholders is missing a translator comment or not. See https://github.com/WordPress/gutenberg/blob/de11ef92c9f6478fedb7bd5f56b1612943d5c7a9/packages/eslint-plugin/rules/i18n-translator-comments.js
While working on #70434 I noticed that the quality of some of the comments is sub-optimal, as they don't actually reference the placeholders.
Bad:
// translators: Current page number in total number of pages
__( 'Page %1$s of %2$s' )
/* translators: The number of items. */
__( '%s items reset.' )
Good:
// translators: 1: current page number. 2: total number of pages.
__( 'Page %1$d of %2$d' )
/* translators: %d: The number of items. */
__( '%d items reset.' ),
What is your proposed solution?
It would be nice if the rule was a bit stricter and used some regex to enforce that every placeholder is mentioned in comment.
They usually follow this format (single placeholder vs multiple):
translators: %d: foo.
translators: %s: bar.
translators: 1: foo. 2: bar.
translators: 1: foo, 2: bar.
translators: 1 is foo. 2 is bar.
translators: 1 is foo, 2 is bar.
USERSATOSHI
Metadata
Metadata
Assignees
Labels
Internationalization (i18n)Issues or PRs related to internationalization effortsIssues or PRs related to internationalization efforts[Status] In ProgressTracking issues with work in progressTracking issues with work in progress[Tool] ESLint plugin/packages/eslint-plugin/packages/eslint-plugin[Type] EnhancementA suggestion for improvement.A suggestion for improvement.