Skip to content

Create Block: Add --textdomain flag to create block tool #69802

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

Merged
merged 2 commits into from
Apr 16, 2025

Conversation

Infinite-Null
Copy link
Contributor

@Infinite-Null Infinite-Null commented Apr 3, 2025

What?

Add a --textdomain parameter option to the create block tool.
Closes: #69798

Why?

Currently, when creating blocks with the --no-plugin parameter in non-interactive mode, the block slug is automatically used as the textdomain. This is problematic when developing a plugin with multiple blocks.

Testing Instructions

  1. Checkout this PR :
gh pr checkout #69802
  1. Create a block with explicit textdomain:
node ./packages/create-block/index.js test-block --no-plugin --textdomain=my-custom-domain
  1. Create a block without textdomain (should use slug):
node ../packages/create-block/index.js another-block --no-plugin

Screencast:

Screen.Recording.2025-04-03.at.12.50.38.PM.mov

@Infinite-Null Infinite-Null changed the title Add --textdomain flag for internationalization support Add --textdomain flag to create block tool Apr 3, 2025
@Infinite-Null Infinite-Null marked this pull request as ready for review April 3, 2025 07:32
Copy link

github-actions bot commented Apr 3, 2025

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: Infinite-Null <ankitkumarshah@git.wordpress.org>
Co-authored-by: gziolo <gziolo@git.wordpress.org>
Co-authored-by: michakrapp <mfgmicha@git.wordpress.org>

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

@Mamaduka Mamaduka added [Type] Enhancement A suggestion for improvement. [Tool] Create Block /packages/create-block labels Apr 3, 2025
@Mamaduka Mamaduka changed the title Add --textdomain flag to create block tool Create Block: Add --textdomain flag to create block tool Apr 3, 2025
Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

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

This looks and tests great. Nice one. Can you add an entry to the CHANGELOG file:

https://github.com/WordPress/gutenberg/blob/trunk/packages/create-block/CHANGELOG.md

This is the only task left to land this PR.

@gziolo gziolo enabled auto-merge (squash) April 16, 2025 08:37
@gziolo
Copy link
Member

gziolo commented Apr 16, 2025

I enabled auto-merge for this PR. It looks like the CHANGELOG file has some merge conflicts to resolve now.

auto-merge was automatically disabled April 16, 2025 08:44

Head branch was pushed to by a user without write access

@Infinite-Null
Copy link
Contributor Author

Infinite-Null commented Apr 16, 2025

Hi @gziolo,
I have resolved the merge conflict and also added the CHANGELOG entry. I think due to my push auto merge is now disabled

@Infinite-Null Infinite-Null requested a review from gziolo April 16, 2025 08:59
@gziolo gziolo enabled auto-merge (squash) April 16, 2025 11:58
@Infinite-Null
Copy link
Contributor Author

Rebasing to fix the failing tests, which were recently fixed in #69912 🚀

auto-merge was automatically disabled April 16, 2025 15:25

Head branch was pushed to by a user without write access

@Infinite-Null Infinite-Null force-pushed the feature/textdomain-cli-option branch from 0f1cae4 to d24229e Compare April 16, 2025 15:25
@Infinite-Null
Copy link
Contributor Author

Hi @gziolo, Really sorry for the inconvenience. I have rebased this PR to get the changes of #69912 which fixes the failing test, and this seems to again turn off the auto merge. Could you please 🙏 enable auto-merge again

@gziolo
Copy link
Member

gziolo commented Apr 16, 2025

No worries. There is something strange happening with PHPUnit tests. I will set it to auto-merge again.

@gziolo gziolo enabled auto-merge (squash) April 16, 2025 15:43
@gziolo gziolo merged commit a083c7e into WordPress:trunk Apr 16, 2025
59 checks passed
@github-actions github-actions bot added this to the Gutenberg 20.8 milestone Apr 16, 2025
@t-hamano
Copy link
Contributor

@Infinite-Null Do you mind submitting a follow-up PR to update the README?

### `options`
```bash
-V, --version output the version number
-t, --template <name> project template type name; allowed values: "static" (default), "es5", the name of an external npm package, or the path to a local directory
--variant choose a block variant as defined by the template
--no-plugin scaffold block files only
--target-dir <directory> the directory where the files will be scaffolded, defaults to the slug
--namespace <value> internal namespace for the block name
--title <value> display title for the block and the WordPress plugin
--short-description <value> short description for the block and the WordPress plugin
--category <name> category name for the block
--wp-scripts enable integration with `@wordpress/scripts` package
--no-wp-scripts disable integration with `@wordpress/scripts` package
--wp-env enable integration with `@wordpress/env` package
-h, --help output usage information
```

@Infinite-Null
Copy link
Contributor Author

Sure @t-hamano 👍,
I will create a follow-up PR shortly

@Infinite-Null
Copy link
Contributor Author

Infinite-Null commented Apr 17, 2025

Hi @t-hamano,
I have opened a follow-up PR #69927 with the updated README.md. Please review it at your convenience.

chriszarate pushed a commit to chriszarate/gutenberg that referenced this pull request Jul 1, 2025
…#69802)

* feat: add --textdomain option for internationalization support

* Add changelog entry

Co-authored-by: Infinite-Null <ankitkumarshah@git.wordpress.org>
Co-authored-by: gziolo <gziolo@git.wordpress.org>
Co-authored-by: michakrapp <mfgmicha@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Tool] Create Block /packages/create-block [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Tool: create-block] Add text-domain flag
4 participants