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

Blocks: move localizable strings out of the metadata attributes field #36724

Merged
merged 5 commits into from
Apr 4, 2024

Conversation

monsieur-z
Copy link
Contributor

@monsieur-z monsieur-z commented Apr 3, 2024

Fixes #36649

Proposed changes:

Block attributes defined in the metadata block.json file are not localizable (see the WordPress.org documentation). This PR updates the following blocks to remove translatable strings from this file:

  • Paid Content
  • Jetpack AI Search
  • Donations
  • Subscriptions
  • Cookie Consent
  • Goodreads
  • Mailchimp

The approach is to remove default strings from the block.json files, define them in a JS file instead, and use them as a fallback when reading the attributes.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

Project thread: pf5801-Aw-p2

Does this pull request change what data or activity we track or use?

No.

Testing instructions:

For each block above, verify that it still works as expected in the editor and in the site (the Cookie Consent block may only be added in the site editor). Ideally, change the language to a language other than English and check that all UI elements are displayed in that language.

Note: if you can't see the text in the language you chose, make sure to update the latest translations in the Update page. You can also check if the translation exists with this tool.

Copy link
Contributor

github-actions bot commented Apr 3, 2024

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WordPress.com Simple site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin, and enable the fix/blocks-non-localized-strings branch.

  • To test on Simple, run the following command on your sandbox:

    bin/jetpack-downloader test jetpack fix/blocks-non-localized-strings
    

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

Copy link
Contributor

github-actions bot commented Apr 3, 2024

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Once your PR is ready for review, check one last time that all required checks appearing at the bottom of this PR are passing or skipped.
Then, add the "[Status] Needs Team Review" label and ask someone from your team review the code. Once reviewed, it can then be merged.
If you need an extra review from someone familiar with the codebase, you can update the labels from "[Status] Needs Team Review" to "[Status] Needs Review", and in that case Jetpack Approvers will do a final review of your PR.


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen daily.
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly. The next release is scheduled for May 7, 2024 (scheduled code freeze on April 29, 2024).

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@@ -50,22 +50,6 @@
"isPremiumContentChild": "isPremiumContentChild"
},
"attributes": {
"newPlanName": {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These attributes are not used anywhere any more. Removing them doesn't break backward compatibility.

@@ -60,88 +60,6 @@ function register_block() {
),
'align' => array( 'wide', 'full' ),
),
'attributes' => array(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Attributes were added back to server-side registration as a temporary workaround (#36695).

@@ -1 +1 @@
<!-- wp:jetpack/subscriptions /-->
<!-- wp:jetpack/subscriptions {"submitButtonText":"Subscribe"} /-->
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've followed how failing tests were fixed in previous similar situations: #27443.

@@ -1,3 +1,3 @@
<!-- wp:jetpack/mailchimp -->
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've followed how failing tests were fixed in previous similar situations: #27443.

Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

When adding a block, the default seems to still be the English version on my end, e.g.:

image image

@monsieur-z
Copy link
Contributor Author

@jeherve, updating the translations should fix this.
Screenshot 2024-04-04 at 9 13 36 AM

@jeherve
Copy link
Member

jeherve commented Apr 4, 2024

updating the translations should fix this.

Thanks! For some reason I had updated the translations, but needed to do once again. ¯_(ツ)_/¯

It works well now.

@jeherve jeherve added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Team Review labels Apr 4, 2024
@monsieur-z monsieur-z merged commit 15b62d0 into trunk Apr 4, 2024
56 checks passed
@monsieur-z monsieur-z deleted the fix/blocks-non-localized-strings branch April 4, 2024 19:01
@github-actions github-actions bot added this to the jetpack/13.3.1 milestone Apr 4, 2024
@github-actions github-actions bot removed the [Status] Ready to Merge Go ahead, you can push that green button! label Apr 4, 2024
@simison simison added the [Type] Bug When a feature is broken and / or not performing as intended label Apr 5, 2024
TimBroddin pushed a commit that referenced this pull request Apr 10, 2024
…#36724)

* Blocks: move localizable strings out of the metadata attributes field

* Fix Goodreads block tests

* Update Subscriptions block test fixtures

* Update Mailchimp block test fixtures
@zinigor zinigor modified the milestones: jetpack/13.3.1, jetpack/13.4 Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] AI Chat [Block] Cookie Consent [Block] Donations [Block] Goodreads [Block] Mailchimp [Block] Paid Content aka Premium Content [Block] Subscriptions [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Tests] Includes Tests [Type] Bug When a feature is broken and / or not performing as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Blocks: attributes defined in blocks.json are not localized properly
4 participants