import { __, _n, sprintf } from '@wordpress/i18n';
import type { Counts } from '../../shared/api/types/status';
import { formatNumber } from '../../shared/lib/numbers';

export function linksLede( counts: Counts, problemTotal: number ): string {
	if ( problemTotal === 0 ) {
		return sprintf(
			/* translators: %s: number of links */
			__( 'All %s links work.', 'aiplaz-link-checkup' ),
			formatNumber( counts.total )
		);
	}

	return sprintf(
		/* translators: 1: number of links with a problem, 2: number of working links */
		_n(
			'%1$s link needs a look. The other %2$s work.',
			'%1$s links need a look. The other %2$s work.',
			problemTotal,
			'aiplaz-link-checkup'
		),
		formatNumber( problemTotal ),
		formatNumber( counts.working )
	);
}
