Skip to content

Commit

Permalink
Admin Page: better handle i18n for disconnection warnings
Browse files Browse the repository at this point in the history
Fixes #18391

Let's ensure that we display the right string regardless of the language and the number of connected plugins.
  • Loading branch information
jeherve committed Jan 18, 2021
1 parent 4da2459 commit 1e74312
Showing 1 changed file with 19 additions and 11 deletions.
Expand Up @@ -8,7 +8,7 @@ import PropTypes from 'prop-types';
* WordPress dependencies
*/
import { createInterpolateElement } from '@wordpress/element';
import { __, _n } from '@wordpress/i18n';
import { __, _n, sprintf } from '@wordpress/i18n';

/**
* Internal dependencies
Expand Down Expand Up @@ -110,11 +110,26 @@ class JetpackTerminationDialogFeatures extends Component {

render() {
const { isDevVersion, purpose, siteBenefits, connectedPlugins } = this.props;

const siteBenefitCount = siteBenefits.length;

const jetpackSupportURl = isDevVersion ? JETPACK_CONTACT_BETA_SUPPORT : JETPACK_CONTACT_SUPPORT;

const connectedPluginsTitle =
1 === connectedPlugins.length
? __(
'The Jetpack Connection is also used by another plugin, and it will lose connection.',
'jetpack'
)
: sprintf(
/* translators: placeholder is a number. */
_n(
'The Jetpack Connection is also used by %d other plugin, and it will lose connection.',
'The Jetpack Connection is also used by %d other plugins, and they will lose connection.',
connectedPlugins.length,
'jetpack'
),
connectedPlugins.length
);

return (
<Card className="jetpack-termination-dialog__features">
<p className="jetpack-termination-dialog__info">
Expand Down Expand Up @@ -164,14 +179,7 @@ class JetpackTerminationDialogFeatures extends Component {
) }
{ connectedPlugins.length > 0 && (
<div className="jetpack-termination-dialog__generic-info">
<h2>
{ _n(
'The Jetpack Connection is also used by another plugin, and it will lose connection.',
'The Jetpack Connection is also used by other plugins, and they will lose connection.',
connectedPlugins.length,
'jetpack'
) }
</h2>
<h2>{ connectedPluginsTitle }</h2>
{ this.renderConnectedPlugins( connectedPlugins ) }
</div>
) }
Expand Down

0 comments on commit 1e74312

Please sign in to comment.