site-kit-wp icon indicating copy to clipboard operation
site-kit-wp copied to clipboard

Idea Hub tabs are not properly localized

Open tofumatt opened this issue 5 years ago • 2 comments

Bug Description

The tabs in the Idea Hub widget (https://github.com/google/site-kit-wp/blob/1919e84c8c7030dcf510710c59dc5f9b50e4aa21/assets/js/modules/idea-hub/components/dashboard/DashboardIdeasWidget/index.js#L186-L189 https://github.com/google/site-kit-wp/blob/1919e84c8c7030dcf510710c59dc5f9b50e4aa21/assets/js/modules/idea-hub/components/dashboard/DashboardIdeasWidget/index.js#L192-L195) are not properly localized and will not be fully translated.

This is because the counts are not part of a translation string. We need to use __ and createInterpolateElement to properly format these tab titles.


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • Idea Hub widget tab titles should be fully translatable.

Implementation Brief

  • Use sprintf, __, and createInterpolateElement to translate the tab titles, eg:
{ savedIdeas?.length >= 0 &&
	createInterpolateElement(
		sprintf(
			/* translators: %s: number of saved Idea Hub ideas */
			__(
				'Saved <span>(%s)</span>',
				'google-site-kit'
			),
			savedIdeas.length
		),
		{
			span: <span />,
		}
	) }
{ savedIdeas?.length === undefined &&
	__( 'Saved', 'google-site-kit' ) }

Test Coverage

  • N/A

Visual Regression Changes

  • None.

QA Brief

  • We don't have any translations for this text yet, but verify the Idea Hub tabs still work as before including outputting the count inside a <span> tag and that the translations contain the entire text of the tab title, as per the ACs

Changelog entry

  • Fix Idea Hub tab localization text.

tofumatt avatar Aug 17 '21 21:08 tofumatt

IB ✅

aaemnnosttv avatar Aug 18 '21 07:08 aaemnnosttv

QA ✅

  • Verified that the count is rendered in a <span>
  • Verified that the translations contain the entire text of the tab title

johnPhillips avatar Aug 22 '21 22:08 johnPhillips