From 4b2672081cb80694675b8663f279c3d11d989e47 Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Wed, 18 Sep 2024 13:39:08 +0100 Subject: [PATCH] Use custom block name in inspector controls when available (#65398) * Output name when available * i18n improvement --- .../src/components/block-card/index.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/block-editor/src/components/block-card/index.js b/packages/block-editor/src/components/block-card/index.js index 8196f7688d4b5..4d40fe07d5547 100644 --- a/packages/block-editor/src/components/block-card/index.js +++ b/packages/block-editor/src/components/block-card/index.js @@ -13,7 +13,7 @@ import { __experimentalVStack as VStack, } from '@wordpress/components'; import { chevronLeft, chevronRight } from '@wordpress/icons'; -import { __, isRTL } from '@wordpress/i18n'; +import { __, isRTL, sprintf } from '@wordpress/i18n'; import { useSelect, useDispatch } from '@wordpress/data'; /** @@ -22,7 +22,7 @@ import { useSelect, useDispatch } from '@wordpress/data'; import BlockIcon from '../block-icon'; import { store as blockEditorStore } from '../../store'; -function BlockCard( { title, icon, description, blockType, className } ) { +function BlockCard( { title, icon, description, blockType, className, name } ) { if ( blockType ) { deprecated( '`blockType` property in `BlockCard component`', { since: '5.7', @@ -65,7 +65,16 @@ function BlockCard( { title, icon, description, blockType, className } ) { ) } -

{ title }

+

+ { name?.length + ? sprintf( + // translators: %1$s: Custom block name. %2$s: Block title. + __( '%1$s (%2$s)' ), + name, + title + ) + : title } +

{ description && ( { description }