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

Add text domain option while scaffolding the block in create-block #57197

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from

Conversation

vampdroid
Copy link

@vampdroid vampdroid commented Dec 19, 2023

What?

Issue - #54980

Why?

  • This PR adds a new option prompt in the create-block command to add text domain option in the scaffolding block's block.json metadata

How?

  • As per the flow of the command goes:
  • If the user calls npx @wordpress/create-block --no-plugin it adds 'textdomain' prompts where the user can specify the text domain for that block.
  • Created a new prompt in the prompts.js for textdomain and added it to scaffold.js and in the plugin template for --no-plugin option. This way it will be shown both with the plugin and no plugin option.

Testing Instructions

  • Open the code editor and terminal
  • Create a folder inside wp-content/plugins
  • Run npx ../gutenberg/packages/create-block --no-plugin. (Make sure you already have the Gutenberg plugin installed and updated with this branch code in plugins folder already)
  • You will see an option The text domain used to internationalize text in the block: after selecting a category where you can specify your text-domain.
  • After the block scaffolding is done, you will be able to see your specified text-domain in block.json of your block folder

Testing Instructions for Keyboard

None

Screenshots or screencast

Screenshot 2023-12-19 at 2 58 54 PM Screenshot 2023-12-19 at 2 59 09 PM

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Dec 19, 2023
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @vampdroid! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@vampdroid vampdroid changed the title Add text domain option while scaffolding the blockin create-block Add text domain option while scaffolding the block in create-block Dec 19, 2023
@gziolo gziolo added the [Tool] Create Block /packages/create-block label Dec 19, 2023
@ryanwelcher ryanwelcher added the [Type] Bug An existing feature does not function as intended label Dec 10, 2024
@ryanwelcher
Copy link
Contributor

@vampdroid thanks for putting this together! Would you be able to address the merge conflicts and update the branch with the latest from trunk?

Copy link

github-actions bot commented Dec 10, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: vampdroid <[email protected]>
Co-authored-by: ryanwelcher <[email protected]>
Co-authored-by: gziolo <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link
Contributor

@ryanwelcher ryanwelcher left a comment

Choose a reason for hiding this comment

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

I may be mistaken, but it looks like this only covers interactive mode. It would be great to also have a --text-domain flag that can be used to pass the text-domain when in quick mode.

@@ -153,6 +153,7 @@ program
'description',
'dashicon',
'category',
'textdomain',
Copy link
Member

Choose a reason for hiding this comment

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

Do you anticipate using different textdomain values for individual blocks, or should it be a setting for the plugin? I can see how this could be useful only when scaffolding a block without a plugin.

Copy link
Author

Choose a reason for hiding this comment

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

So currently this is applied to the block if used with --no-plugin flag and to both if this flag isn't passed.

The solution would be to offer another prompt that shows up in the plugin section in the regular flow, but also when creating a block without a plugin.

I think this should be the ideal scenario right?

const textdomain = {
type: 'input',
name: 'textdomain',
message: 'The text domain used to internationalize text in the block:',
Copy link
Member

Choose a reason for hiding this comment

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

Again, the question is whether this setting should apply primarily to the plugin or block.

@gziolo gziolo added the [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. label Dec 11, 2024
@gziolo
Copy link
Member

gziolo commented Dec 11, 2024

I added the [Status] Stale label to the PR. I am happy to remove it as soon as the branch is refreshed with the latest changes in trunk.

@vampdroid
Copy link
Author

Sure @gziolo, I will be updating the PR as soon as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. [Tool] Create Block /packages/create-block [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants