How to use the @wordpress/i18n.sprintf function in @wordpress/i18n

To help you get started, we’ve selected a few @wordpress/i18n examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github moderntribe / events-gutenberg / plugins / events-pro / src / modules / data / status / sagas.js View on Github external
const { items_created, last_created_at } = response;

			const date = momentUtils.toDate( momentUtils.toMoment( last_created_at ) );

			// Show editing notice
			yield call(
				[ wpDispatch( 'core/editor' ), 'createSuccessNotice' ],
				NOTICES[ NOTICE_EDITING_SERIES ],
				{ id: NOTICE_EDITING_SERIES, isDismissible: false }
			);

			// Show progress notice
			yield call(
				[ wpDispatch( 'core/editor' ), 'createSuccessNotice' ],
				`${ sprintf( NOTICES[ NOTICE_PROGRESS_ON_SERIES_CREATION_COUNT ], items_created ) } ${ sprintf( NOTICES[ NOTICE_PROGRESS_ON_SERIES_CREATION ], date ) }`,
				{ id: NOTICE_PROGRESS_ON_SERIES_CREATION, isDismissible: true }
			);
		}

		if ( yield select( selectors.isCompleted ) ) {
			yield put( allowEdits() ); // Allow datetime block to be editable again
			// Remove editing notice
			yield call(
				[ wpDispatch( 'core/editor' ), 'removeNotice' ],
				NOTICE_EDITING_SERIES
			);
			yield call(
				[ wpDispatch( 'core/editor' ), 'removeNotice' ],
				NOTICE_PROGRESS_ON_SERIES_CREATION
			);
			break; // We done
github WordPress / gutenberg / editor / components / inserter / menu.js View on Github external
componentDidUpdate( prevProps, prevState ) {
		const searchResults = this.searchItems( this.props.items );
		// Announce the search results to screen readers.
		if ( this.state.filterValue && !! searchResults.length ) {
			this.props.debouncedSpeak( sprintf( _n(
				'%d result found',
				'%d results found',
				searchResults.length
			), searchResults.length ), 'assertive' );
		} else if ( this.state.filterValue ) {
			this.props.debouncedSpeak( __( 'No results.' ), 'assertive' );
		}

		if ( this.state.tab !== prevState.tab ) {
			this.tabContainer.scrollTop = this.tabScrollTop[ this.state.tab ];
		}
	}
github WordPress / gutenberg / packages / editor / src / components / post-title / index.native.js View on Github external
focusedBorderColor,
			borderStyle,
		} = this.props;

		const decodedPlaceholder = decodeEntities( placeholder );
		const borderColor = this.props.isSelected ? focusedBorderColor : 'transparent';

		return (
github WordPress / gutenberg / packages / editor / src / components / post-publish-modal / prepublish.js View on Github external
function PostPublishModalPrepublish( {
	hasPublishAction,
	publishDate,
	isFloating,
	visibility,
	children,
	postType,
} ) {
	const postLabel = get( postType, [ 'labels', 'singular_name' ] );
	let prePublishBodyText,
		prePublishDateText;

	if ( ! hasPublishAction ) {
		prePublishBodyText = __( 'When you’re ready, submit your work for review, and an Editor will be able to approve it for you.' );
	} else {
		prePublishBodyText = sprintf(
			/* translators: %s: post type singular name */
			__( 'Double-check your settings, then publish your %s.' ), postLabel
		);
	}

	if ( isFloating ) {
		prePublishDateText = __( 'Your work will be published right now.' );
	} else if ( new Date( publishDate ) < new Date() ) {
		prePublishDateText = __( 'Your work will be published right now and back-dated.' );
	} else {
		prePublishDateText = __( 'Your work will be published at the specified date and time.' );
	}

	const getVisibilityInfo = () => find( visibilityOptions, { value: visibility } ).info;

	return (
github htmlburger / carbon-fields / packages / core / fields / association / index.js View on Github external
addFilter( 'carbon-fields.association.validate', 'carbon-fields/core', ( field, value ) => {
	const { min, required } = field;

	if ( required && isEmpty( value ) ) {
		return __( 'This field is required.', 'carbon-fields-ui' );
	}

	if ( min > 0 && value.length < min ) {
		return sprintf( __( 'Minimum number of items not reached (%s items)', 'carbon-fields-ui' ), [ field.min ] );
	}

	return null;
} );
github WordPress / gutenberg / packages / editor / src / components / post-taxonomies / flat-term-selector.js View on Github external
return null;
		}

		const { loading, availableTerms, selectedTerms } = this.state;
		const termNames = availableTerms.map( ( term ) => term.name );
		const newTermLabel = get(
			taxonomy,
			[ 'labels', 'add_new_item' ],
			slug === 'post_tag' ? __( 'Add New Tag' ) : __( 'Add New Term' )
		);
		const singularName = get(
			taxonomy,
			[ 'labels', 'singular_name' ],
			slug === 'post_tag' ? __( 'Tag' ) : __( 'Term' )
		);
		const termAddedLabel = sprintf( _x( '%s added', 'term' ), singularName );
		const termRemovedLabel = sprintf( _x( '%s removed', 'term' ), singularName );
		const removeTermLabel = sprintf( _x( 'Remove %s', 'term' ), singularName );

		return (
github Automattic / vip-go-mu-plugins-built / jetpack / extensions / blocks / publicize / form-unwrapped.js View on Github external
<div>
							<textarea rows="{" for="" placeholder="{" maxlength="{" disabled="{" value="{" id="{">							&lt;div className={ characterCountClass }&gt;
								{ sprintf(
									_n(
										'%d character remaining',
										'%d characters remaining',
										charactersRemaining,
										'jetpack'
									),
									charactersRemaining
								) }
							&lt;/div&gt;
						&lt;/div&gt;
					&lt;/Fragment&gt;
				) }
			&lt;/div&gt;
		);
	}
}</textarea></div>
github Automattic / wp-calypso / client / gutenberg / extensions / map-block / edit.js View on Github external
{ __( 'Update Key' ) }
							
							<button type="button">
								{ __( 'Remove Key' ) }
							</button>
						
					
				
			
		);
		const placholderAPIStateLoading = (
			
				
			
		);
		const getAPIInstructions = sprintf(
			"This is your first map block. You need to get a Google Maps API key. <a href="%s">Here's how to do it</a>.",
			'https://developers.google.com/maps/documentation/javascript/get-api-key'
		);
		const placeholderAPIStateFailure = (
			
				
					<div>
						{ getAPIInstructions }
					</div>
github Automattic / wp-calypso / packages / jetpack-blocks / src / blocks / contact-form / components / jetpack-contact-form.jsx View on Github external
if ( errors.length === 1 ) {
				if ( errors[ 0 ] && errors[ 0 ].email ) {
					return sprintf( __( '%s is not a valid email address.' ), errors[ 0 ].email );
				}
				return errors[ 0 ];
			}

			if ( errors.length === 2 ) {
				return sprintf(
					__( '%s and %s are not a valid email address.' ),
					errors[ 0 ].email,
					errors[ 1 ].email
				);
			}
			const inValidEmails = errors.map( error => error.email );
			return sprintf( __( '%s are not a valid email address.' ), inValidEmails.join( ', ' ) );
		}
		return null;
	}

@wordpress/i18n

WordPress internationalization (i18n) library.

GPL-2.0-or-later
Latest version published 1 day ago

Package Health Score

98 / 100
Full package analysis