Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing translations #1227

Merged
merged 8 commits into from
Mar 6, 2020
Merged
9 changes: 3 additions & 6 deletions assets/js/components/analytics-inactive-cta.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ class AnalyticsInactiveCTA extends Component {

render() {
const {
title,
description,
ctaLabel,
title = __( 'Learn more about what visitors do on your site.', 'google-site-kit' ),
description = __( 'Connecting with Google Analytics to see unique vistors, goal completions, top pages and more.', 'google-site-kit' ),
ctaLabel = __( 'Set up Analytics', 'google-site-kit' ),
} = this.props;

const { canManageOptions } = global.googlesitekit.permissions;
Expand All @@ -87,9 +87,6 @@ AnalyticsInactiveCTA.propTypes = {
};

AnalyticsInactiveCTA.defaultProps = {
title: __( 'Learn more about what visitors do on your site.', 'google-site-kit' ),
description: __( 'Connecting with Google Analytics to see unique vistors, goal completions, top pages and more.', 'google-site-kit' ),
ctaLabel: __( 'Set up Analytics', 'google-site-kit' ),
};

export default AnalyticsInactiveCTA;
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { __ } from '@wordpress/i18n';
class DashboardSplashIntro extends Component {
render() {
const {
title,
title = __( 'Welcome to Site Kit.', 'google-site-kit' ),
description,
buttonLabel,
onButtonClick,
Expand Down Expand Up @@ -89,7 +89,6 @@ DashboardSplashIntro.propTypes = {
};

DashboardSplashIntro.defaultProps = {
title: __( 'Welcome to Site Kit.', 'google-site-kit' ),
};

export default DashboardSplashIntro;
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { __ } from '@wordpress/i18n';
class DashboardSplashOutro extends Component {
render() {
const {
description,
description = __( 'Bringing the best of Google tools to WordPress.', 'google-site-kit' ),
buttonLabel,
onButtonClick,
} = this.props;
Expand Down Expand Up @@ -77,7 +77,6 @@ DashboardSplashOutro.propTypes = {
};

DashboardSplashOutro.defaultProps = {
description: __( 'Bringing the best of Google tools to WordPress.', 'google-site-kit' ),
};

export default DashboardSplashOutro;
5 changes: 4 additions & 1 deletion assets/js/components/modules-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ class ModulesList extends Component {
) }
{ ! isConnected && blockedByParentModule && (
<Link disabled small inherit>
{ sprintf( __( 'Enable %s to start setup', 'google-site-kit' ), parentBlockerName ) }
{
/* translators: %s: parent module name */
sprintf( __( 'Enable %s to start setup', 'google-site-kit' ), parentBlockerName )
}
</Link>
) }
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class DashboardSetupAlerts extends Component {
<Fragment>
<Notification
id={ winData.id }
/* translators: %s: the name of a module that setup was completed for */
title={ sprintf( __( 'Congrats on completing the setup for %s!', 'google-site-kit' ), winData.setupTitle ) }
description={ winData.description }
handleDismiss={ () => {} }
Expand Down
1 change: 1 addition & 0 deletions assets/js/components/notifications/data-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import { __, sprintf } from '@wordpress/i18n';
*/
const getDataErrorComponent = ( moduleName, error, inGrid = false, fullWidth = false, createGrid = false ) => {
const cta = <CTA
/* translators: %s: module name */
title={ sprintf( __( 'Data error in %s', 'google-site-kit' ), moduleName ) }
description={ error }
error
Expand Down
8 changes: 2 additions & 6 deletions assets/js/components/notifications/notification-counter.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,8 @@ class NotificationCounter extends Component {

render() {
const screenReader = sprintf(
_n(
'%d notification',
'%d notifications',
this.state.count,
'google-site-kit'
),
/* translators: %d: the number of notifications */
_n( '%d notification', '%d notifications', this.state.count, 'google-site-kit' ),
this.state.count
);

Expand Down
20 changes: 17 additions & 3 deletions assets/js/components/optin.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import classnames from 'classnames';
*/
import apiFetch from '@wordpress/api-fetch';
import { Component } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { __, sprintf } from '@wordpress/i18n';

/**
* Internal dependencies
Expand All @@ -38,6 +38,7 @@ import {
toggleTracking,
trackEvent,
} from '../util/tracking';
import { sanitizeHTML } from '../util';

class OptIn extends Component {
constructor( props ) {
Expand Down Expand Up @@ -99,6 +100,12 @@ class OptIn extends Component {
className,
} = this.props;

const labelHTML = sprintf(
/* translators: %s: privacy policy URL */
__( 'Help us improve the Site Kit plugin by allowing tracking of anonymous usage stats. All data are treated in accordance with <a href="%s" target="_blank" rel="noopener noreferrer">Google Privacy Policy</a>', 'google-site-kit' ),
'https://policies.google.com/privacy'
);

return (
<div className={ classnames(
'googlesitekit-opt-in',
Expand All @@ -111,8 +118,15 @@ class OptIn extends Component {
checked={ optIn }
onChange={ this.handleOptIn }
>
{ __( 'Help us improve the Site Kit plugin by allowing tracking of anonymous usage stats. All data are treated in accordance with ', 'google-site-kit' ) }
<a href="https://policies.google.com/privacy" target="_blank" rel="noopener noreferrer">{ __( 'Google Privacy Policy', 'google-site-kit' ) }</a>.
Comment on lines -114 to -115
Copy link
Collaborator Author

@aaemnnosttv aaemnnosttv Mar 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incorrect because strings can't be properly translated when concatenated. This also renders oddly in some cases, e.g. in Español where the translation is missing the space at the end so the text and the link are running together.

<span
dangerouslySetInnerHTML={ sanitizeHTML(
labelHTML,
{
ALLOWED_TAGS: [ 'a' ],
ALLOWED_ATTR: [ 'href', 'target', 'rel' ],
}
) }
/>
</Checkbox>
{ error &&
<div className="googlesitekit-error-text">
Expand Down
15 changes: 13 additions & 2 deletions assets/js/components/settings/settings-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ class SettingsModule extends Component {
'googlesitekit-settings-module__status-icon--connected' :
'googlesitekit-settings-module__status-icon--not-connected';

/* translators: %s: module name */
const subtitle = sprintf( __( 'By disconnecting the %s module from Site Kit, you will no longer have access to:', 'google-site-kit' ), name );

const isSavingModule = isSaving === `${ slug }-module`;
Expand Down Expand Up @@ -284,7 +285,9 @@ class SettingsModule extends Component {
<p className="googlesitekit-settings-module__status">
{
isConnected ?
/* translators: %s: module name */
sprintf( __( '%s is connected', 'google-site-kit' ), name ) :
/* translators: %s: module name */
sprintf( __( '%s is not connected', 'google-site-kit' ), name )
}
<span className={ classnames(
Expand Down Expand Up @@ -396,7 +399,10 @@ class SettingsModule extends Component {
inherit
danger
>
{ sprintf( __( 'Disconnect %s from Site Kit', 'google-site-kit' ), name ) }
{
/* translators: %s: module name */
sprintf( __( 'Disconnect %s from Site Kit', 'google-site-kit' ), name )
}
<SvgIcon
className="googlesitekit-settings-module__remove-button-icon"
id="trash"
Expand All @@ -412,7 +418,10 @@ class SettingsModule extends Component {
inherit
external
>
{ sprintf( __( 'See full details in %s', 'google-site-kit' ), name ) }
{
/* translators: %s: module name */
sprintf( __( 'See full details in %s', 'google-site-kit' ), name )
}
</Link>
) }
</div>
Expand All @@ -423,13 +432,15 @@ class SettingsModule extends Component {
<Dialog
dialogActive={ dialogActive }
handleDialog={ this.handleDialog }
/* translators: %s: module name */
title={ sprintf( __( 'Disconnect %s from Site Kit?', 'google-site-kit' ), name ) }
subtitle={ subtitle }
onKeyPress={ this.handleCloseModal }
provides={ provides }
handleConfirm={ this.handleConfirmRemoveModule }
dependentModules={ dependentModules ?
sprintf(
/* translators: %s: module name */
__( 'these active modules depend on %s and will also be disconnected: ', 'google-site-kit' ),
name
) + dependentModules : false
Expand Down
4 changes: 3 additions & 1 deletion assets/js/components/setup-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,10 @@ class SetupModule extends Component {
>
{
! blockedByParentModule ?
/* translators: %s: module name */
sprintf( __( 'Set up %s', 'google-site-kit' ), name ) :
sprintf( __( 'Setup Analytics to gain access to %s', 'google-site-kit' ), name )
/* translators: %s: module name */
sprintf( __( 'Set up Analytics to gain access to %s', 'google-site-kit' ), name )
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed from "Setup Analytics" to "Set up Analytics" for consistency, but also because it is the correct form to use here. This caused VRT to fail, hence updates for those as well.

}
</Link>
</p>
Expand Down
4 changes: 2 additions & 2 deletions assets/js/components/setup/setup-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ class SetupUsingProxy extends Component {
description = __( 'Site Kit will no longer have access to your account. If you’d like to reconnect Site Kit, click "Start Setup" below to generate new credentials.', 'google-site-kit' );
startSetupText = __( 'Sign in with Google', 'google-site-kit' );
} else if ( isSecondAdmin ) {
title = __( 'Sign in with Google to configure Site Kit' );
description = __( 'To use Site Kit, sign in with your Google account. The Site Kit service will guide you through 3 simple steps to complete the connection and configure the plugin.' );
title = __( 'Sign in with Google to configure Site Kit', 'google-site-kit' );
description = __( 'To use Site Kit, sign in with your Google account. The Site Kit service will guide you through 3 simple steps to complete the connection and configure the plugin.', 'google-site-kit' );
startSetupText = __( 'Sign in with Google', 'google-site-kit' );
} else {
title = __( 'Sign in with Google to set up Site Kit', 'google-site-kit' );
Expand Down
3 changes: 1 addition & 2 deletions assets/js/modules/adsense/settings/adsense-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class AdSenseSettings extends Component {
} = this.state;
const {
isEditing,
switchLabel,
switchLabel = __( 'Let Site Kit place code on your site', 'google-site-kit' ),
switchOnMessage,
switchOffMessage,
} = this.props;
Expand Down Expand Up @@ -200,7 +200,6 @@ AdSenseSettings.defaultProps = {
isEditing: false,
accountTagMatch: false,
existingTag: false,
switchLabel: __( 'Let Site Kit place code on your site', 'google-site-kit' ),
switchOnMessage: '',
switchOffMessage: '',
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,12 @@ class AnalyticsDashboardWidgetTopAcquisitionSources extends Component {
},
{
title: __( 'New Users', 'google-site-kit' ),
/* translators: %s: date range */
tooltip: sprintf( __( 'Number of new users to visit your page over %s', 'google-site-kit' ), dateRangeFrom ),
},
{
title: __( 'Sessions', 'google-site-kit' ),
/* translators: %s: date range */
tooltip: sprintf( __( 'Number of sessions users had on your website over %s', 'google-site-kit' ), dateRangeFrom ),
},
{
Expand Down
3 changes: 3 additions & 0 deletions assets/js/modules/analytics/dashboard/dashboard-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ class AnalyticsDashboardWidget extends Component {
) }>
<Layout
header
/* translators: %s: date range */
title={ sprintf( __( 'Audience overview for the last %s', 'google-site-kit' ), dateRangeFrom ) }
headerCtaLabel={ __( 'See full stats in Analytics', 'google-site-kit' ) }
headerCtaLink="http://analytics.google.com"
Expand All @@ -208,6 +209,7 @@ class AnalyticsDashboardWidget extends Component {
<Layout
header
footer
/* translators: %s: date range */
title={ sprintf( __( 'Top content over the last %s', 'google-site-kit' ), dateRangeFrom ) }
headerCtaLink="https://analytics.google.com"
headerCtaLabel={ __( 'See full stats in Analytics', 'google-site-kit' ) }
Expand All @@ -225,6 +227,7 @@ class AnalyticsDashboardWidget extends Component {
<Layout
header
footer
/* translators: %s: date range */
title={ sprintf( __( 'Top acquisition sources over the last %s', 'google-site-kit' ), dateRangeFrom ) }
headerCtaLink="https://analytics.google.com"
headerCtaLabel={ __( 'See full stats in Analytics', 'google-site-kit' ) }
Expand Down
3 changes: 2 additions & 1 deletion assets/js/modules/analytics/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -1102,7 +1102,8 @@ class AnalyticsSetup extends Component {
}

{ !! existingTag &&
<p>{ sprintf( __( 'An existing analytics tag was found on your site with the id %s. If later on you decide to replace this tag, Site Kit can place the new tag for you. Make sure you remove the old tag first.', 'google-site-kit' ), existingTag ) }</p>
/* translators: %s: Analytics tag ID */
<p>{ sprintf( __( 'An existing analytics tag was found on your site with the ID %s. If later on you decide to replace this tag, Site Kit can place the new tag for you. Make sure you remove the old tag first.', 'google-site-kit' ), existingTag ) }</p>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capitalized "ID"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt that this translator comment is going to be picked up. It should be inside the brackets, preceding either sprintf or ideally the __() call.

<p>{
sprintf(
	/* translators: %s: Analytics tag ID */
	__( 'An existing analytics tag was found on your site with the ID %s. If later on you decide to replace this tag, Site Kit can place the new tag for you. Make sure you remove the old tag first.', 'google-site-kit' ),
	existingTag
)
}</p>

}

{ this.renderErrorOrNotice() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,18 @@ class SearchConsoleDashboardWidgetSiteStats extends Component {

setOptions() {
const { selectedStats, series, vAxes } = this.props;
const { pageTitle } = global.googlesitekit;

const pageTitle = global.googlesitekit.pageTitle && global.googlesitekit.pageTitle.length ? sprintf( __( 'Search Traffic Summary for %s', 'google-site-kit' ), decodeHtmlEntity( global.googlesitekit.pageTitle ) ) : __( 'Search Traffic Summary', 'google-site-kit' );
let title = __( 'Search Traffic Summary', 'google-site-kit' );

if ( pageTitle && pageTitle.length ) {
/* translators: %s: page title */
title = sprintf( __( 'Search Traffic Summary for %s', 'google-site-kit' ), decodeHtmlEntity( pageTitle ) );
}
Comment on lines +50 to +55
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ESLint rules weren't properly detecting the translators string in a multiline ternary so I split it up this way, which is probably cleaner anyway 😄

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense 👍

With the ternary it wouldn't be clear which __() call it should be associated with.


const options = {
chart: {
title: pageTitle,
title,
},
curveType: 'line',
height: 270,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ class GoogleSitekitSearchConsoleDashboardWidget extends Component {
) }>
<Layout
header
/* translators: %s: date range */
title={ sprintf( __( 'Overview for the last %s', 'google-site-kit' ), dateRangeFrom ) }
headerCtaLabel={ __( 'See full stats in Search Console', 'google-site-kit' ) }
headerCtaLink={ searchConsoleDeepLink }
Expand All @@ -207,6 +208,7 @@ class GoogleSitekitSearchConsoleDashboardWidget extends Component {
wrapperClass
) }>
<Layout
/* translators: %s: date range */
title={ sprintf( __( 'Top search queries over the last %s', 'google-site-kit' ), dateRangeFrom ) }
header
footer
Expand Down
8 changes: 2 additions & 6 deletions assets/js/util/standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,8 @@ export const appendNotificationsCount = ( count = 0 ) => {
const screenReader = document.createElement( 'span' );
screenReader.setAttribute( 'class', 'screen-reader-text' );
screenReader.textContent = sprintf(
_n(
'%d notification',
'%d notifications',
count,
'google-site-kit'
),
/* translators: %d is the number of notifications */
_n( '%d notification', '%d notifications', count, 'google-site-kit' ),
count
);

Expand Down