Skip to content

Commit

Permalink
Fix block insertion a11y string (#28871)
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad authored Feb 10, 2021
1 parent a5eb7fe commit 2ee3481
Showing 1 changed file with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
/**
* External dependencies
*/
import { castArray } from 'lodash';

/**
* WordPress dependencies
*/
import { useDispatch, useSelect } from '@wordpress/data';
import { isUnmodifiedDefaultBlock } from '@wordpress/blocks';
import { _n } from '@wordpress/i18n';
import { _n, sprintf } from '@wordpress/i18n';
import { speak } from '@wordpress/a11y';
import { useCallback } from '@wordpress/element';

Expand Down Expand Up @@ -127,11 +132,14 @@ function useInsertionPoint( {
}

if ( ! selectBlockOnInsert ) {
// translators: %d: the name of the block that has been added
const message = _n(
'%d block added.',
'%d blocks added.',
blocks.length
const message = sprintf(
// translators: %d: the name of the block that has been added
_n(
'%d block added.',
'%d blocks added.',
castArray( blocks ).length
),
castArray( blocks ).length
);
speak( message );
}
Expand Down

0 comments on commit 2ee3481

Please sign in to comment.