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
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/create-block/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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?

],
variant
).filter( filterOptionsProvided );
Expand Down
14 changes: 14 additions & 0 deletions packages/create-block/lib/prompts.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,19 @@ const category = {
choices: [ 'text', 'media', 'design', 'widgets', 'theme', 'embed' ],
};

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.

validate( input ) {
if ( ! /^[a-z][a-z0-9\-]*$/.test( input ) ) {
return 'Invalid text domain specified. Text domain can contain only lowercase alphanumeric characters or dashes, and start with a letter.';
}

return true;
},
};

// Plugin header fields.
const pluginURI = {
type: 'input',
Expand Down Expand Up @@ -141,6 +154,7 @@ module.exports = {
description,
dashicon,
category,
textdomain,
pluginURI,
version,
author,
Expand Down
3 changes: 2 additions & 1 deletion packages/create-block/lib/scaffold.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module.exports = async (
description,
dashicon,
category,
textdomain,
attributes,
supports,
author,
Expand Down Expand Up @@ -89,7 +90,7 @@ module.exports = async (
customPackageJSON,
customBlockJSON,
example,
textdomain: slug,
textdomain,
gziolo marked this conversation as resolved.
Show resolved Hide resolved
} );

const view = {
Expand Down
Loading