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

ESLint: Enable and enforce remaining i18n rules for the plugin (e.g. no trailing spaces) #60196

Merged
merged 9 commits into from
Aug 21, 2024
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ module.exports = {
'@wordpress/dependency-group': 'error',
'@wordpress/wp-global-usage': 'error',
'@wordpress/react-no-unsafe-timeout': 'error',
'@wordpress/i18n-hyphenated-range': 'error',
'@wordpress/i18n-no-flanking-whitespace': 'error',
'@wordpress/i18n-text-domain': [
'error',
{
Expand Down
6 changes: 3 additions & 3 deletions lib/experiments-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function gutenberg_initialize_experiments_settings() {

add_settings_field(
'gutenberg-sync-collaboration',
__( 'Live Collaboration and offline persistence ', 'gutenberg' ),
__( 'Live Collaboration and offline persistence', 'gutenberg' ),
'gutenberg_display_experiment_field',
'gutenberg-experiments',
'gutenberg_experiments_section',
Expand Down Expand Up @@ -93,7 +93,7 @@ function gutenberg_initialize_experiments_settings() {

add_settings_field(
'gutenberg-form-blocks',
__( 'Form and input blocks ', 'gutenberg' ),
__( 'Form and input blocks', 'gutenberg' ),
'gutenberg_display_experiment_field',
'gutenberg-experiments',
'gutenberg_experiments_section',
Expand All @@ -105,7 +105,7 @@ function gutenberg_initialize_experiments_settings() {

add_settings_field(
'gutenberg-grid-interactivity',
__( 'Grid interactivity ', 'gutenberg' ),
__( 'Grid interactivity', 'gutenberg' ),
'gutenberg_display_experiment_field',
'gutenberg-experiments',
'gutenberg_experiments_section',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function ConvertToGroupButton( {
>
{ _x(
'Ungroup',
'Ungrouping blocks from within a grouping block back into individual blocks within the Editor '
'Ungrouping blocks from within a grouping block back into individual blocks within the Editor'
) }
</MenuItem>
) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ function BackgroundImageControls( {
onResetImage();
} }
>
{ __( 'Reset ' ) }
{ __( 'Reset' ) }
</MenuItem>
) }
</MediaReplaceFlow>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,10 @@ export default function getGlobalStylesChanges( next, previous, options = {} ) {
}, {} )
).map( ( [ key, changeValues ] ) => {
const changeValuesLength = changeValues.length;
const joinedChangesValue = changeValues.join( __( ', ' ) );
const joinedChangesValue = changeValues.join(
/* translators: Used between list items, there is a space after the comma. */
__( ', ' ) // eslint-disable-line @wordpress/i18n-no-flanking-whitespace
);
switch ( key ) {
case 'blocks': {
return sprintf(
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/group/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function GroupEditControls( { tagName, onSelectTagName } ) {
'The <header> element should represent introductory content, typically a group of introductory or navigational aids.'
),
main: __(
'The <main> element should be used for the primary content of your document only. '
'The <main> element should be used for the primary content of your document only.'
),
section: __(
"The <section> element should represent a standalone portion of the document that can't be better represented by another element."
Expand Down
7 changes: 5 additions & 2 deletions packages/block-library/src/post-navigation-link/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ export default function PostNavigationLinkEdit( {
const displayArrow = arrowMap[ arrow ];

if ( showTitle ) {
/* translators: Label before for next and previous post. There is a space after the colon. */
swissspidy marked this conversation as resolved.
Show resolved Hide resolved
placeholder = isNext ? __( 'Next: ' ) : __( 'Previous: ' );
placeholder = isNext
? /* translators: Label before for next and previous post. There is a space after the colon. */
__( 'Next: ' ) // eslint-disable-line @wordpress/i18n-no-flanking-whitespace
: /* translators: Label before for next and previous post. There is a space after the colon. */
__( 'Previous: ' ); // eslint-disable-line @wordpress/i18n-no-flanking-whitespace
}

const ariaLabel = isNext ? __( 'Next post' ) : __( 'Previous post' );
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/query/edit/query-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export default function QueryContent( {
} );
const htmlElementMessages = {
main: __(
'The <main> element should be used for the primary content of your document only. '
'The <main> element should be used for the primary content of your document only.'
),
section: __(
"The <section> element should represent a standalone portion of the document that can't be better represented by another element."
Expand Down
22 changes: 13 additions & 9 deletions packages/edit-post/src/components/welcome-guide/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,20 @@ export default function WelcomeGuideDefault() {
{ __( 'Learn how to use the block editor' ) }
</h1>
<p className="edit-post-welcome-guide__text">
{ __(
'New to the block editor? Want to learn more about using it? '
{ createInterpolateElement(
__(
"New to the block editor? Want to learn more about using it? <a>Here's a detailed guide.</a>"
),
{
a: (
<ExternalLink
href={ __(
'https://wordpress.org/documentation/article/wordpress-block-editor/'
) }
/>
),
}
) }
<ExternalLink
href={ __(
'https://wordpress.org/documentation/article/wordpress-block-editor/'
) }
>
{ __( "Here's a detailed guide." ) }
</ExternalLink>
</p>
</>
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,11 @@ function InstalledFonts() {
} catch ( error ) {
setNotice( {
type: 'error',
message:
__( 'There was an error updating the font family. ' ) +
error.message,
message: sprintf(
/* translators: %s: error message */
__( 'There was an error updating the font family. %s' ),
error.message
),
} );
}
};
Expand Down Expand Up @@ -464,7 +466,7 @@ function ConfirmDeleteDialog( {
setNotice( {
type: 'error',
message:
__( 'There was an error uninstalling the font family. ' ) +
__( 'There was an error uninstalling the font family.' ) +
error.message,
} );
}
Expand Down
22 changes: 13 additions & 9 deletions packages/edit-widgets/src/components/welcome-guide/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,20 @@ export default function WelcomeGuide() {
{ __( 'Learn how to use the block editor' ) }
</h1>
<p className="edit-widgets-welcome-guide__text">
{ __(
'New to the block editor? Want to learn more about using it? '
{ createInterpolateElement(
__(
"New to the block editor? Want to learn more about using it? <a>Here's a detailed guide.</a>"
),
{
a: (
<ExternalLink
href={ __(
'https://wordpress.org/documentation/article/wordpress-block-editor/'
) }
/>
),
}
) }
<ExternalLink
href={ __(
'https://wordpress.org/documentation/article/wordpress-block-editor/'
) }
>
{ __( "Here's a detailed guide." ) }
</ExternalLink>
</p>
</>
),
Expand Down
22 changes: 13 additions & 9 deletions packages/editor/src/components/page-attributes/parent.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,16 +274,20 @@ export function ParentRow() {
}
) }
<p>
{ __(
'They also show up as sub-items in the default navigation menu. '
{ createInterpolateElement(
__(
'They also show up as sub-items in the default navigation menu. <a>Learn more.</a>'
),
{
a: (
<ExternalLink
href={ __(
'https://wordpress.org/documentation/article/page-post-settings-sidebar/#page-attributes'
) }
/>
),
}
) }
<ExternalLink
href={ __(
'https://wordpress.org/documentation/article/page-post-settings-sidebar/#page-attributes'
) }
>
{ __( 'Learn more' ) }
</ExternalLink>
</p>
</div>
<PageAttributesParent />
Expand Down
24 changes: 15 additions & 9 deletions packages/editor/src/components/post-url/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import { useSelect, useDispatch } from '@wordpress/data';
import { safeDecodeURIComponent, cleanForSlug } from '@wordpress/url';
import { useState } from '@wordpress/element';
import { useState, createInterpolateElement } from '@wordpress/element';
import { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';
import { __ } from '@wordpress/i18n';
import {
Expand Down Expand Up @@ -83,14 +83,20 @@ export default function PostURL( { onClose } ) {
<VStack spacing={ 3 }>
{ isEditable && (
<div>
{ __( 'Customize the last part of the URL. ' ) }
<ExternalLink
href={ __(
'https://wordpress.org/documentation/article/page-post-settings-sidebar/#permalink'
) }
>
{ __( 'Learn more.' ) }
</ExternalLink>
{ createInterpolateElement(
__(
'Customize the last part of the URL. <a>Learn more.</a>'
),
{
a: (
<ExternalLink
href={ __(
'https://wordpress.org/documentation/article/page-post-settings-sidebar/#permalink'
) }
/>
),
}
) }
</div>
) }
<div>
Expand Down
Loading