site-kit-wp icon indicating copy to clipboard operation
site-kit-wp copied to clipboard

Update translation of formatted strings with multiple placeholders

Open jimmymadon opened this issue 3 years ago • 3 comments

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$s or %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, tests in 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

jimmymadon avatar Jun 28 '22 09:06 jimmymadon

IB ✔️

eugene-manuilov avatar Aug 11 '22 12:08 eugene-manuilov

@makiost could you please add an estimate to this ticket?

eugene-manuilov avatar Aug 11 '22 12:08 eugene-manuilov

Set it as a generous 7, as there are over 100 file matches to review. 👍

maciejost avatar Aug 11 '22 12:08 maciejost

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)

wpdarren avatar Sep 19 '22 01:09 wpdarren