javascript icon indicating copy to clipboard operation
javascript copied to clipboard

The WordOccurrences component should use `_n()` for proper translation

Open afercia opened this issue 5 years ago • 1 comments

Explanation

The WordOccurrences component uses a translatable string that doesn't take into account singular / plural forms:

sprintf( __( "%d occurrences", "yoast-components" ), occurrence )

Instead, it should use _n() to provide singular / plural strings, taking into account whether there's just 1 occurrence or more occurrences:

sprintf(
	/* translators: %d: Prominent words occurrences. */
	_n( "%d occurrence", "%d occurrences", occurrence, "yoast-components" ),
	occurrence
)

To reproduce

  • go to the standalone app demo > WordOccurrences tab
  • change one of the words occurrences to 1
  • inspect the source in your dev tools
  • see the string is incorrect: 1 occurrences

Technical decisions

Feedback?

afercia avatar Sep 05 '19 12:09 afercia

Patched at https://github.com/Yoast/javascript/pull/353

afercia avatar Sep 05 '19 12:09 afercia