From 8741ca90db2de0bf66662fd8070e529f4be4c507 Mon Sep 17 00:00:00 2001 From: Mario Santos Date: Wed, 28 Feb 2024 17:09:51 +0100 Subject: [PATCH] Update message logic to handle translations --- packages/block-library/src/image/edit.js | 12 +++++++----- packages/block-library/src/image/image.js | 24 +++++++++++++---------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/packages/block-library/src/image/edit.js b/packages/block-library/src/image/edit.js index c7b3b034deb42..489343e1dfef7 100644 --- a/packages/block-library/src/image/edit.js +++ b/packages/block-library/src/image/edit.js @@ -351,11 +351,13 @@ export function ImageEdit( { !! metadata?.bindings?.url && ( ! blockBindingsSource || blockBindingsSource?.lockAttributesEditing ), - lockUrlControlsMessage: sprintf( - /* translators: %s: Label of the bindings source if exists */ - __( 'Connected to %s' ), - blockBindingsSource?.label || __( 'dynamic data' ) - ), + lockUrlControlsMessage: blockBindingsSource?.label + ? sprintf( + /* translators: %s: Label of the bindings source. */ + __( 'Connected to %s' ), + blockBindingsSource.label + ) + : __( 'Connected to dynamic data' ), }; }, [ isSingleSelected ] diff --git a/packages/block-library/src/image/image.js b/packages/block-library/src/image/image.js index 3b17f25cf9bd9..e55f6bfa03d73 100644 --- a/packages/block-library/src/image/image.js +++ b/packages/block-library/src/image/image.js @@ -456,20 +456,24 @@ export default function Image( { !! altBinding && ( ! altBindingSource || altBindingSource?.lockAttributesEditing ), - lockAltControlsMessage: sprintf( - /* translators: %s: Label of the bindings source if exists */ - __( 'Connected to %s' ), - altBindingSource?.label || __( 'dynamic data' ) - ), + lockAltControlsMessage: altBindingSource?.label + ? sprintf( + /* translators: %s: Label of the bindings source. */ + __( 'Connected to %s' ), + altBindingSource.label + ) + : __( 'Connected to dynamic data' ), lockTitleControls: !! titleBinding && ( ! titleBindingSource || titleBindingSource?.lockAttributesEditing ), - lockTitleControlsMessage: sprintf( - /* translators: %s: Label of the bindings source if exists */ - __( 'Connected to %s' ), - titleBindingSource?.label || __( 'dynamic data' ) - ), + lockTitleControlsMessage: titleBindingSource?.label + ? sprintf( + /* translators: %s: Label of the bindings source. */ + __( 'Connected to %s' ), + titleBindingSource.label + ) + : __( 'Connected to dynamic data' ), }; }, [ clientId, isSingleSelected, metadata?.bindings ]