How to use the @wordpress/i18n._n 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 Automattic / jetpack / modules / search / instant-search / components / search-result.jsx View on Github external
className="jetpack-instant-search__result-title"
				>
					{ strip( this.props.result.fields.title_html ) || 'Unknown Title' }
				{' '}
				<div>
					{ strip( this.props.result.fields.author ) }{' '}
					<span>
						{ strip( this.props.result.fields.date ).split( ' ' )[ 0 ] }
					</span>
				</div>
				<div>
					{ strip( this.props.result.fields.excerpt_html ) }
				</div>
				<div>
					{ sprintf(
						_n( '%d comment', '%d comments', this.props.result.fields.comment_count, 'jetpack' ),
						this.props.result.fields.comment_count
					) }
				</div>
			
		);
	}
}
github Automattic / jetpack / extensions / blocks / map / lookup / index.js View on Github external
announce( filteredOptions ) {
		const { debouncedSpeak } = this.props;
		if ( ! debouncedSpeak ) {
			return;
		}
		if ( filteredOptions.length ) {
			debouncedSpeak(
				sprintf(
					_n(
						'%d result found, use up and down arrow keys to navigate.',
						'%d results found, use up and down arrow keys to navigate.',
						filteredOptions.length,
						'jetpack',
						'jetpack'
					),
					filteredOptions.length
				),
				'assertive'
			);
		} else {
			debouncedSpeak( __( 'No results.', 'jetpack' ), 'assertive' );
		}
	}
	render() {
github inspireui / mstore / wordpress / wp-content / plugins / woocommerce / packages / woocommerce-blocks / assets / js / components / product-control / index.js View on Github external
{ getInteractionIcon( isSelected ) }
					

					<span>
						<span>
					</span>

					{ variationsCount ? (
						<span>
							{ sprintf(
								_n(
									'%d variation',
									'%d variations',
									variationsCount,
									'woocommerce'
								),
								variationsCount
							) }
						</span>
					) : null }
				,
				expandedProduct === item.id &amp;&amp;
					variationsCount &gt; 0 &amp;&amp;
					variationsLoading &amp;&amp; (
						</span>
github Automattic / newspack-plugin / assets / wizards / updates / views / devInfo / index.js View on Github external
);
			} );
	}, [] );

	if ( error ) {
		return <div>{ error }</div>;
	}

	const { date, content, bugFixes = [], features = [] } = parseReleaseHeader( releaseData );

	const bugFixesAmountString = sprintf(
		_n( '%d bug', '%d bugs', bugFixes.length, 'newspack' ),
		bugFixes.length
	);
	const featuresAmountString = sprintf(
		_n( '%d new feature', '%d new features', features.length, 'newspack' ),
		features.length
	);

	const infoStrings = [
		...( bugFixes.length ? [ `${ __( 'fixing', 'newspack' ) } ${ bugFixesAmountString }` ] : [] ),
		...( features.length ? [ `${ __( 'adding', 'newspack' ) } ${ featuresAmountString }` ] : [] ),
	];

	return releaseData ? (
		<details>
			<summary>
				<div>
					
				</div>
				<span>
					<strong>{ repoName }</strong> { __( 'was released', 'newspack' ) }{' '}</span></summary></details>
github woocommerce / woocommerce-gutenberg-products-block / assets / js / components / product-tag-control / index.js View on Github external
selected: ( n ) =>
				sprintf(
					_n(
						'%d tag selected',
						'%d tags selected',
						n,
						'woo-gutenberg-products-block'
					),
					n
				),
			updated: __(
github Automattic / jetpack / modules / search / instant-search / components / search-results.jsx View on Github external
getSearchTitle() {
		const { total = 0, corrected_query = false } = this.props.response;
		const hasQuery = this.props.query !== '';
		const hasCorrectedQuery = corrected_query !== false;
		const num = new Intl.NumberFormat().format( total );

		if ( hasQuery && hasCorrectedQuery ) {
			return sprintf(
				_n( 'Showing %s result for "%s"', 'Showing %s results for "%s"', total, 'jetpack' ),
				num,
				corrected_query
			);
		} else if ( hasQuery ) {
			return sprintf(
				_n( '%s result for "%s"', '%s results for "%s"', total, 'jetpack' ),
				num,
				this.props.query
			);
		}
		return sprintf( _n( '%s result', '%s results', total, 'jetpack' ), num );
	}
github WordPress / gutenberg / packages / block-editor / src / components / inserter / menu.js View on Github external
reusableItems,
			itemsPerCategory,
			openPanels: this.filterOpenPanels(
				filterValue,
				itemsPerCategory,
				filteredItems,
				reusableItems
			),
		} );

		const resultCount = Object.keys( itemsPerCategory ).reduce( ( accumulator, currentCategorySlug ) => {
			return accumulator + itemsPerCategory[ currentCategorySlug ].length;
		}, 0 );

		const resultsFoundMessage = sprintf(
			_n( '%d result found.', '%d results found.', resultCount ),
			resultCount
		);
		debouncedSpeak( resultsFoundMessage );
	}
github Automattic / wp-calypso / client / gutenberg / extensions / map-block / lookup / index.js View on Github external
announce( filteredOptions ) {
		const { debouncedSpeak } = this.props;
		if ( ! debouncedSpeak ) {
			return;
		}
		if ( !! filteredOptions.length ) {
			debouncedSpeak(
				sprintf(
					_n(
						'%d result found, use up and down arrow keys to navigate.',
						'%d results found, use up and down arrow keys to navigate.',
						filteredOptions.length,
						'jetpack'
					),
					filteredOptions.length
				),
				'assertive'
			);
		} else {
			debouncedSpeak( __( 'No results.', 'jetpack' ), 'assertive' );
		}
	}
	render() {
github Yoast / wordpress-seo / js / src / structured-data-blocks / how-to / utils / buildDurationString.js View on Github external
function transformDurationsToStrings( { days, hours, minutes } ) {
	const strings = [];
	if ( days !== 0 ) {
		strings.push( sprintf( _n( "%d day", "%d days", days, "wordpress-seo" ), days ) );
	}
	if ( hours !== 0 ) {
		strings.push( sprintf( _n( "%d hour", "%d hours", hours, "wordpress-seo" ), hours ) );
	}
	if ( minutes !== 0 ) {
		strings.push( sprintf( _n( "%d minute", "%d minutes", minutes, "wordpress-seo" ), minutes ) );
	}
	return strings;
}

@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