Skip to content

Commit

Permalink
Use sprintf for copy link
Browse files Browse the repository at this point in the history
  • Loading branch information
getdave authored and scruffian committed Feb 7, 2024
1 parent 0e857f4 commit e91e505
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import classnames from 'classnames';
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { __, sprintf } from '@wordpress/i18n';
import {
Button,
ExternalLink,
Expand Down Expand Up @@ -137,10 +137,12 @@ export default function LinkPreview( {
) }
<Button
icon={ copySmall }
// Ends up looking like "Copy link: https://example.com"
label={ `${ __( 'Copy link' ) }${
isEmptyURL ? '' : `: ${ value.url }`
}` }
label={ sprintf(
// Translators: %1$s is a placeholder for an optional colon, %2$s is a placeholder for the link URL (if present).
__( 'Copy link%1$s%2$s' ), // Ends up looking like "Copy link: https://example.com".
isEmptyURL ? '' : ': ',
value.url
) }
ref={ ref }
disabled={ isEmptyURL }
size="compact"
Expand Down

0 comments on commit e91e505

Please sign in to comment.