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: Add rule to prevent usage of the word 'sidebar' in translatable strings #68894

Merged
merged 9 commits into from
Feb 12, 2025
6 changes: 6 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ const restrictedSyntax = [
'CallExpression[callee.name=/^(__|_x|_n|_nx)$/] > Literal[value=/^toggle\\b/i]',
message: "Avoid using the verb 'Toggle' in translatable strings",
},
{
selector:
'CallExpression[callee.name=/^(__|_x|_n|_nx)$/] > Literal[value=/(?<![-\\w])sidebar(?![-\\w])/i]',
message:
"Avoid using the word 'sidebar' in translatable strings. Consider using 'panel' instead.",
},
];

/** `no-restricted-syntax` rules for components. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ function AddCustomGenericTemplateModalContent( { onClose, createTemplate } ) {
placeholder={ defaultTitle }
disabled={ isBusy }
help={ __(
// eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts
'Describe the template, e.g. "Post with sidebar". A custom template can be manually applied to any post or page.'
) }
/>
Expand Down
1 change: 1 addition & 0 deletions packages/edit-site/src/components/welcome-guide/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export default function WelcomeGuidePage() {
</h1>
<p className="edit-site-welcome-guide__text">
{ __(
// eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts
'It’s now possible to edit page content in the site editor. To customise other parts of the page like the header and footer switch to editing the template using the settings sidebar.'
) }
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default function WidgetAreas( { selectedWidgetAreaId } ) {
let description;
if ( ! selectedWidgetArea ) {
description = __(
// eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts
'Widget Areas are global parts in your site’s layout that can accept blocks. These vary by theme, but are typically parts like your Sidebar or Footer.'
);
} else if ( selectedWidgetAreaId === 'wp_inactive_widgets' ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export default function CreateNewTemplateModal( { onClose } ) {
placeholder={ DEFAULT_TITLE }
disabled={ isBusy }
help={ __(
// eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts
'Describe the template, e.g. "Post with sidebar". A custom template can be manually applied to any post or page.'
) }
/>
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/src/components/preferences-modal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function PreferencesModalContents( { extraSections = {} } ) {
scope="core"
featureName="showListViewByDefault"
help={ __(
'Opens the List View sidebar by default.'
'Opens the List View panel by default.'
) }
label={ __( 'Always open List View' ) }
/>
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/src/components/sidebar/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const SidebarHeader = ( _, ref ) => {
return {
documentLabel:
// translators: Default label for the Document sidebar tab, not selected.
getPostTypeLabel() || _x( 'Document', 'noun, sidebar' ),
getPostTypeLabel() || _x( 'Document', 'noun, panel' ),
};
}, [] );

Expand Down
2 changes: 1 addition & 1 deletion packages/editor/src/components/sidebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const SidebarContent = ( {
headerClassName="editor-sidebar__panel-tabs"
title={
/* translators: button label text should, if possible, be under 16 characters. */
_x( 'Settings', 'sidebar button label' )
_x( 'Settings', 'panel button label' )
}
toggleShortcut={ keyboardShortcut }
icon={ isRTL() ? drawerLeft : drawerRight }
Expand Down
Loading