site-kit-wp
site-kit-wp copied to clipboard
Update translation of formatted strings with multiple placeholders
Feature Description
Translator comments with multiple placeholders sometimes contain the entire placeholder variable name, as in the below example. https://github.com/google/site-kit-wp/blob/6874c2e65ac45e4c1da65473a9a66669a8db3d6e/assets/js/components/setup/CompatibilityChecks/CompatibilityErrorNotice.js#L151
These should be converted to integers only, like: https://github.com/google/site-kit-wp/blob/6874c2e65ac45e4c1da65473a9a66669a8db3d6e/assets/js/modules/adsense/components/setup/SetupAccountCreate.js#L98
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- Translated format strings that use multiple placeholders should always use position-explicit placeholders (e.g.
%1$sor%2$d) rather than implicit%s %d - Translators comments for such formatted strings should use integers to refer to the argument used by the placeholders, rather than the full placeholder itself
Implementation Brief
- Using your editor, search for implicit translation string placeholders (JS and PHP) with files related to testing excluded (
*.test.js, *test.php, testsin VS Code) - Jump from result to result and update any instances with more than one result to use position-explicit placeholders, as outlined in the AC
- Update the
translators:comment to point to the position of the placeholder, e.g:/* translators: 1: Title prefix. 2: Title. */ - Search through the project for translation comments containing the full placeholder (
translators: %1$) and update them to only use the position integer
Test Coverage
- No new tests needed.
QA Brief
Changelog entry
IB ✔️
@makiost could you please add an estimate to this ticket?
Set it as a generous 7, as there are over 100 file matches to review. 👍
QA Update: ✅
Verified:
- Looking at the AC/IB this seems to be a change to the code comments so shouldn't have an impact on the plugin. What I did though is ran through the setting up of the modules for a new site. I also connected a site that has live data and could not see any issues on the Site Kit Dashboard (main and entity)