javascript
                                
                                 javascript copied to clipboard
                                
                                    javascript copied to clipboard
                            
                            
                            
                        The WordOccurrences component should use `_n()` for proper translation
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?
Patched at https://github.com/Yoast/javascript/pull/353