-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Add text domain option while scaffolding the block in create-block #57197
Conversation
👋 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 thanks for putting this together! Would you be able to address the merge conflicts and update the branch with the latest from trunk? |
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this 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.
I added the |
Sure @gziolo, I will be updating the PR as soon as possible. |
I added the changelog entry in dccf1d1 as preparations for landing this PR. |
I checked the documentation for plugins: https://developer.wordpress.org/plugins/internationalization/how-to-internationalize-your-plugin/#text-domains
We still need this option for the case when scaffolding the block without the plugin because the |
One Idea I've been toying with is accessing In the case of adding another block to an existing plugin, it may be possible scan the There's a lot of edge cases here based on where files are located but it might be worth a look? |
I like the direction in which your thoughts are going. Based on my previous comment, it feels like detecting in some magic way the slug of the theme or the plugin would also solve the issue. As for this PR, is there anything left to do? @ryanwelcher, does it work for you as expected? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It worked correctly in my testing.
@vampdroid, thank you for contributing this new option.
@ryanwelcher, I landed it so I can rebase the Inquirer.js usage together with #67877. If you have some ideas how to iterate on it, I'm happy to help with follow-up PRs.
I was thinking about it a bit. Based on my comment #57197 (comment), my understanding is that when scaffolding a full plugin, |
What?
Fixes #54980
Why?
create-block
command to addtext domain
option in the scaffolding block's block.json metadataHow?
npx @wordpress/create-block --no-plugin
it adds 'textdomain' prompts where the user can specify the text domain for that block.--no-plugin
option. This way it will be shown both with the plugin and no plugin option.Testing Instructions
wp-content/plugins
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)The text domain used to internationalize text in the block:
after selecting a category where you can specify your text-domain.block.json
of your block folderTesting Instructions for Keyboard
None
Screenshots or screencast