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

Use namespace for textdomain when --no-plugin is in use #54980

Open
samhermes opened this issue Oct 2, 2023 · 4 comments
Open

Use namespace for textdomain when --no-plugin is in use #54980

samhermes opened this issue Oct 2, 2023 · 4 comments
Labels
Good First Issue An issue that's suitable for someone looking to contribute for the first time Needs Dev Ready for, and needs developer efforts [Tool] Create Block /packages/create-block [Type] Bug An existing feature does not function as intended

Comments

@samhermes
Copy link

Description

When scaffolding a new block with @wordpress/create-block and the --no-plugin flag, the textdomain in block.json is being set to the slug of the block. In the case where a plugin has already been set up (when --no-plugin would be used) and additional blocks are being added to it, this means that each block has the wrong textdomain. It's more likely that the namespace for each block will be better to use for the textdomain, as it should be consistent across blocks. Alternatively, a custom textdomain could be set up during the interactive scaffolding process, or the ability to set a default in the block metadata template.

Step-by-step reproduction instructions

  1. Run npx @wordpress/create-block --no-plugin in the blocks directory of an existing plugin.
  2. Respond to the questions, giving the block a slug and a namespace.
  3. After the block is scaffolded successfully, open block.json and see that the textdomain has been set to the slug instead of the namespace.

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@gziolo gziolo added [Tool] Create Block /packages/create-block [Type] Bug An existing feature does not function as intended labels Oct 2, 2023
@foosantos foosantos added the Needs Technical Feedback Needs testing from a developer perspective. label Oct 7, 2023
@gziolo
Copy link
Member

gziolo commented Nov 24, 2023

Thank you for the report. That's a valid issue because we assume that the slug used for the plugin is the same as textdomain which is the default for WP plugins, but obviously it could get customized:

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.

@gziolo gziolo added Needs Dev Ready for, and needs developer efforts Good First Issue An issue that's suitable for someone looking to contribute for the first time and removed Needs Technical Feedback Needs testing from a developer perspective. labels Nov 24, 2023
@vampdroid
Copy link

Hi, I created this PR which makes another prompt in the block scaffolding flow to add textdomain which will further be added in block.json meta data. LMK if there are any suggestions or changes to be made in this 🙌 .

@gziolo
Copy link
Member

gziolo commented Dec 19, 2023

@vampdroid, thank you for working on it. I hope it won't take too long to review and test it. I'll keep an eye on it.

@ryanwelcher
Copy link
Contributor

@vampdroid I added some comments to the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good First Issue An issue that's suitable for someone looking to contribute for the first time Needs Dev Ready for, and needs developer efforts [Tool] Create Block /packages/create-block [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

5 participants