fix: fixed all instances of translator lint rule violations (#41450)

* fix: fixed all instances of translator lint rule violations

* Add changefile(s) from automation for the following project(s): @woocommerce/eslint-plugin, @woocommerce/components, woocommerce

* fix i18n lint violations in @woo/components

* fix all i18n lint rule violations in @woo/product-editor

* Add changefile(s) from automation for the following project(s): @woocommerce/product-editor, @woocommerce/eslint-plugin, @woocommerce/components, woocommerce

* empty commit to trigger CI

---------

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
RJ 2023-11-16 19:15:11 +08:00 committed by GitHub
parent 5b209199a0
commit b61b86545a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
47 changed files with 103 additions and 34 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: dev
Fixed some i18n related lint rule violations.

View File

@ -0,0 +1,4 @@
Significance: patch
Type: dev
Fix all lint rule violations for @wordpress/i18n lint rules

View File

@ -141,7 +141,6 @@ class NumberFilter extends Component {
let labelFormat = '';
if ( filter.rule === 'lessthan' ) {
/* eslint-disable-next-line max-len */
/* translators: Sentence fragment, "maximum amount" refers to a numeric value the field must be less than. Screenshot for context: https://cloudup.com/cmv5CLyMPNQ */
labelFormat = _x(
'%(field)s maximum amount',
@ -149,7 +148,6 @@ class NumberFilter extends Component {
'woocommerce'
);
} else {
/* eslint-disable-next-line max-len */
/* translators: Sentence fragment, "minimum amount" refers to a numeric value the field must be more than. Screenshot for context: https://cloudup.com/cmv5CLyMPNQ */
labelFormat = _x(
'%(field)s minimum amount',
@ -198,7 +196,6 @@ class NumberFilter extends Component {
type: inputType,
value: rangeStart || '',
label: sprintf(
/* eslint-disable-next-line max-len */
/* translators: Sentence fragment, "range start" refers to the first of two numeric values the field must be between. Screenshot for context: https://cloudup.com/cmv5CLyMPNQ */
__( '%(field)s range start', 'woocommerce' ),
{ field: get( config, [ 'labels', 'add' ] ) }
@ -211,7 +208,6 @@ class NumberFilter extends Component {
type: inputType,
value: rangeEnd || '',
label: sprintf(
/* eslint-disable-next-line max-len */
/* translators: Sentence fragment, "range end" refers to the second of two numeric values the field must be between. Screenshot for context: https://cloudup.com/cmv5CLyMPNQ */
__( '%(field)s range end', 'woocommerce' ),
{ field: get( config, [ 'labels', 'add' ] ) }

View File

@ -101,6 +101,7 @@ class DatePicker extends Component {
label={ __( 'Choose a date', 'woocommerce' ) }
error={ error }
describedBy={ sprintf(
/* translators: %s: date format specification */
__(
'Date input describing a selected date in format %s',
'woocommerce'

View File

@ -194,6 +194,7 @@ class DateRange extends Component {
label={ __( 'Start Date', 'woocommerce' ) }
error={ afterError }
describedBy={ sprintf(
/* translators: %s: date format specification */
__(
"Date input describing a selected date range's start date in format %s",
'woocommerce'
@ -212,6 +213,7 @@ class DateRange extends Component {
label={ __( 'End Date', 'woocommerce' ) }
error={ beforeError }
describedBy={ sprintf(
/* translators: %s: date format specification */
__(
"Date input describing a selected date range's end date in format %s",
'woocommerce'

View File

@ -47,12 +47,16 @@ export default {
'woocommerce'
),
chooseAvailableStartDate: ( { date } ) =>
/* translators: %s: start date */
sprintf( __( 'Select %s as a start date.', 'woocommerce' ), date ),
chooseAvailableEndDate: ( { date } ) =>
/* translators: %s: end date */
sprintf( __( 'Select %s as an end date.', 'woocommerce' ), date ),
chooseAvailableDate: ( { date } ) => date,
dateIsUnavailable: ( { date } ) =>
/* translators: %s: unavailable date which was selected */
sprintf( __( '%s is not selectable.', 'woocommerce' ), date ),
dateIsSelected: ( { date } ) =>
/* translators: %s: selected date successfully */
sprintf( __( 'Selected. %s', 'woocommerce' ), date ),
};

View File

@ -120,6 +120,7 @@ class D3Legend extends Component {
title={
numberOfRowsVisible >= selectionLimit
? sprintf(
/* translators: %d: number of items selected */
__(
'You may select up to %d items.',
'woocommerce'

View File

@ -100,6 +100,7 @@ export const Tree = forwardRef( function ForwardedTree(
<Icon icon={ plus } size={ 20 } />
{ props.createValue
? sprintf(
/* translators: %s: create value */
__( 'Create "%s"', 'woocommerce' ),
props.createValue
)

View File

@ -108,7 +108,11 @@ export function PageArrowsWithPicker( {
min={ 1 }
max={ pageCount }
/>
{ sprintf( __( 'of %d', 'woocommerce' ), pageCount ) }
{ sprintf(
/* translators: %d: total number of pages */
__( 'of %d', 'woocommerce' ),
pageCount
) }
<Button
className={ nextLinkClass }
icon={ chevronRight }

View File

@ -60,7 +60,8 @@ export function PageArrows( {
aria-live="polite"
>
{ sprintf(
__( 'Page %d of %d', 'woocommerce' ),
/* translators: 1: current page number, 2: total number of pages */
__( 'Page %1$d of %2$d', 'woocommerce' ),
currentPage,
pageCount
) }

View File

@ -54,6 +54,7 @@ const Rating = ( {
};
const label = sprintf(
/* translators: %1$s: rating, %2$s: total number of stars */
__( '%1$s out of %2$s stars.', 'woocommerce' ),
rating,
totalStars

View File

@ -30,6 +30,7 @@ import Tag from '../tag';
const defaultMessages = {
clear: __( 'Clear all selected items', 'woocommerce' ),
noItems: __( 'No items found.', 'woocommerce' ),
/* translators: %s: search term */
noResults: __( 'No results for %s', 'woocommerce' ),
search: __( 'Search for items', 'woocommerce' ),
selected: ( n ) =>

View File

@ -74,6 +74,7 @@ class Tags extends Component< Props > {
return null;
}
const screenReaderLabel = sprintf(
/* translators: %1$s: tag label, %2$s: tag number, %3$s: total number of tags */
__( '%1$s (%2$s of %3$s)', 'woocommerce' ),
item.label,
i + 1,

View File

@ -64,18 +64,23 @@ const SummaryNumber = ( {
let screenReaderLabel =
delta > 0
? sprintf(
? // eslint-disable-next-line @wordpress/valid-sprintf -- false positive from %%
sprintf(
/* translators: percentage change upwards */
__( 'Up %f%% from %s', 'woocommerce' ),
delta,
prevLabel
)
: sprintf(
: // eslint-disable-next-line @wordpress/valid-sprintf -- false positive from %%
sprintf(
/* translators: percentage change downwards */
__( 'Down %f%% from %s', 'woocommerce' ),
Math.abs( delta ),
prevLabel
);
if ( ! delta ) {
screenReaderLabel = sprintf(
/* translators: previous value */
__( 'No change from %s', 'woocommerce' ),
prevLabel
);
@ -150,7 +155,9 @@ const SummaryNumber = ( {
>
<Text variant="caption" size="12" lineHeight="16px">
{ ! isNil( delta )
? sprintf(
? // eslint-disable-next-line @wordpress/valid-sprintf -- false positive from %%
sprintf(
/* translators: percentage change */
__( '%f%%', 'woocommerce' ),
delta
)

View File

@ -244,6 +244,7 @@ const Table: React.VFC< TableProps > = ( {
const iconLabel =
sortedBy === key && sortDir !== ASC
? sprintf(
/* translators: %s: column label */
__(
'Sort by %s in ascending order',
'woocommerce'
@ -251,6 +252,7 @@ const Table: React.VFC< TableProps > = ( {
screenReaderLabel || label
)
: sprintf(
/* translators: %s: column label */
__(
'Sort by %s in descending order',
'woocommerce'

View File

@ -22,6 +22,7 @@ const ViewMoreList = ( { items } ) => {
<Tag
className="woocommerce-view-more-list"
label={ sprintf(
/* translators: %d: number of items more to view */
__( '+%d more', 'woocommerce' ),
items.length - 1
) }

View File

@ -0,0 +1,4 @@
Significance: patch
Type: dev
Fixed some i18n related lint rule violations.

View File

@ -18,7 +18,6 @@ module.exports = {
// temporary conversion to warnings until the below are all handled.
'jsdoc/check-line-alignment': 'warn',
'jsdoc/require-returns-check': 'warn',
'@wordpress/i18n-translator-comments': 'warn',
'@wordpress/i18n-text-domain': [
'error',
{
@ -34,7 +33,6 @@ module.exports = {
'jsdoc/require-param': 'off',
// Making use of typescript no-shadow instead, fixes issues with enum.
'no-shadow': 'off',
'@wordpress/valid-sprintf': 'warn',
'@wordpress/no-unsafe-wp-apis': 'warn',
'@wordpress/no-global-active-element': 'warn',
'import/no-extraneous-dependencies': 'warn',

View File

@ -0,0 +1,4 @@
Significance: patch
Type: dev
Fixed some i18n related lint rule violations.

View File

@ -0,0 +1,4 @@
Significance: patch
Type: dev
Lint fixes for @wordpress/i18n lint rule violation

View File

@ -47,8 +47,8 @@ export function Edit( {
parseFloat( value ) < min
) {
return sprintf(
// translators: %d is the minimum value of the number input.
__(
// translators: %d is the minimum value of the number input.
'Value must be greater than or equal to %d',
'woocommerce'
),
@ -61,8 +61,8 @@ export function Edit( {
parseFloat( value ) > max
) {
return sprintf(
// translators: %d is the maximum value of the number input.
__(
// translators: %d is the maximum value of the number input.
'Value must be less than or equal to %d',
'woocommerce'
),

View File

@ -355,6 +355,7 @@ export const AttributeControl: React.FC< AttributeControlProps > = ( {
{ removingAttribute && (
<RemoveConfirmationModal
title={ sprintf(
/* translators: %s is the attribute name that is being removed */
__( 'Delete %(attributeName)s', 'woocommerce' ),
{ attributeName: removingAttribute.name }
) }

View File

@ -146,7 +146,7 @@ export const EditAttributeModal: React.FC< EditAttributeModalProps > = ( {
deletions
);
if ( additions && deletions ) {
return sprintf( '%s, %s.', additionsMessage, deletionsMessage );
return sprintf( '%1$s, %2$s.', additionsMessage, deletionsMessage );
} else if ( additions ) {
return sprintf( '%s.', additionsMessage );
}

View File

@ -56,7 +56,8 @@ export const AttributeListItem: React.FC< AttributeListItemProps > = ( {
{ attribute.options.length > 3 && (
<Tag
label={ sprintf(
__( '+ %i more', 'woocommerce' ),
/* translators: %i: number of additional attribute values that are hidden */
__( '+ %d more', 'woocommerce' ),
attribute.options.length - 2
) }
/>

View File

@ -73,8 +73,8 @@ export function ManageDownloadLimitsModal( {
setErrors( ( current ) => ( {
...current,
downloadLimit: sprintf(
// translators: %d is the minimum value of the number input.
__(
// translators: %d is the minimum value of the number input.
'Download limit must be greater than or equal to %d',
'woocommerce'
),
@ -107,8 +107,8 @@ export function ManageDownloadLimitsModal( {
setErrors( ( current ) => ( {
...current,
downloadExpiry: sprintf(
// translators: %d is the minimum value of the number input.
__(
// translators: %d is the minimum value of the number input.
'Expiry period must be greater than or equal to %d',
'woocommerce'
),

View File

@ -31,8 +31,10 @@ class CategoriesReport extends Component {
? 'item-comparison'
: 'time-comparison';
const itemsLabel = isSingleCategoryView
? __( '%d products', 'woocommerce' )
: __( '%d categories', 'woocommerce' );
? /* translators: %d: number of products */
__( '%d products', 'woocommerce' )
: /* translators: %d: number of categories */
__( '%d categories', 'woocommerce' );
return {
isSingleCategoryView,

View File

@ -24,6 +24,7 @@ class CouponsReport extends Component {
query.coupons.split( ',' ).length > 1;
const mode = isCompareView ? 'item-comparison' : 'time-comparison';
/* translators: %d: number of coupons */
const itemsLabel = __( '%d coupons', 'woocommerce' );
return {

View File

@ -199,7 +199,8 @@ class OrdersReportTable extends Component {
: [],
formattedProducts.map( ( product ) => ( {
label: sprintf(
__( '%s× %s', 'woocommerce' ),
/* translators: 1: quantity, 2: product name */
__( '%1$s× %2$s', 'woocommerce' ),
product.quantity,
product.label
),
@ -209,7 +210,8 @@ class OrdersReportTable extends Component {
value: formattedProducts
.map( ( { quantity, label } ) =>
sprintf(
__( '%s× %s', 'woocommerce' ),
/* translators: %1$s: quantity, %2$s: product name */
__( '%1$s× %2$s', 'woocommerce' ),
quantity,
label
)

View File

@ -39,8 +39,10 @@ class ProductsReport extends Component {
: 'products';
const label =
isSingleProductView && isSingleProductVariable
? __( '%d variations', 'woocommerce' )
: __( '%d products', 'woocommerce' );
? /* translators: %d: number of variations */
__( '%d variations', 'woocommerce' )
: /* translators: %d: number of products */
__( '%d products', 'woocommerce' );
return {
compareObject,

View File

@ -215,6 +215,7 @@ class ProductsReportTable extends Component {
{ productCategories.length > 1 && (
<Tag
label={ sprintf(
/* translators: %d: number of categories */
_x(
'+%d more',
'categories',

View File

@ -20,6 +20,7 @@ class TaxesReport extends Component {
const { query } = this.props;
const isCompareTaxView = query.filter === 'compare-taxes';
const mode = isCompareTaxView ? 'item-comparison' : 'time-comparison';
/* translators: %d: number of taxes */
const itemsLabel = __( '%d taxes', 'woocommerce' );
return {

View File

@ -24,6 +24,7 @@ const getChartMeta = ( { query } ) => {
return {
compareObject: 'variations',
/* translators: %d: number of variations */
itemsLabel: __( '%d variations', 'woocommerce' ),
mode: isCompareView ? 'item-comparison' : 'time-comparison',
};

View File

@ -31,6 +31,7 @@ const filteredOrderStatuses = Object.keys( ORDER_STATUSES )
value: key,
label: ORDER_STATUSES[ key ],
description: sprintf(
/* translators: %s: non-refunded order statuses to exclude */
__( 'Exclude the %s status from reports', 'woocommerce' ),
ORDER_STATUSES[ key ]
),
@ -64,6 +65,7 @@ const orderStatusOptions = [
value: key,
label: key,
description: sprintf(
/* translators: %s: unregistered order statuses to exclude */
__( 'Exclude the %s status from reports', 'woocommerce' ),
key
),

View File

@ -5,12 +5,14 @@ import { __, sprintf } from '@wordpress/i18n';
import { isNil } from 'lodash';
function HistoricalDataProgress( { label, progress, total } ) {
/* translators: %s: label */
const labelText = sprintf( __( 'Imported %(label)s', 'woocommerce' ), {
label,
} );
const labelCounters = ! isNil( total )
? sprintf( __( '%(progress)s of %(total)s', 'woocommerce' ), {
? /* translators: 1: progress, 2: total */
sprintf( __( '%(progress)s of %(total)s', 'woocommerce' ), {
progress: progress || 0,
total,
} )

View File

@ -46,6 +46,7 @@ function HistoricalDataStatus( { importDate, status } ) {
importDate === -1
? __( 'All historical data imported', 'woocommerce' )
: sprintf(
/* translators: %s: YYYY-MM-DD formatted date */
__(
'Historical data from %s onward imported',
'woocommerce'

View File

@ -103,7 +103,8 @@ class CartModal extends Component {
if ( themeInfo ) {
listItems.push( {
title: sprintf(
__( '%s — %s per year', 'woocommerce' ),
/* translators: 1: theme title, 2: theme price */
__( '%1$s — %2$s per year', 'woocommerce' ),
themeInfo.title,
decodeEntities( themeInfo.price )
),

View File

@ -210,6 +210,7 @@ const CustomizableDashboard = ( { defaultDateRange, path, query } ) => {
) }
className="woocommerce-dashboard-section__add-more-btn"
title={ sprintf(
/* translators: %s: dashboard section titles which are hidden, this button allows unhiding them */
__(
'Add %s section',
'woocommerce'

View File

@ -66,13 +66,11 @@ class ChartBlock extends Component {
this.getChartPath( selectedChart )
) }
>
{
{ sprintf(
/* translators: %s is the chart type */
sprintf(
__( '%s Report', 'woocommerce' ),
selectedChart.label
)
}
__( '%s Report', 'woocommerce' ),
selectedChart.label
) }
</a>
<ReportChart
charts={ charts }

View File

@ -103,6 +103,7 @@ function renderOrders( orders, customers, getFormattedOrderTotal ) {
<>
{ interpolateComponents( {
mixedString: sprintf(
/* translators: 1: order number, 2: customer name */
__(
'{{orderLink}}Order #%(orderNumber)s{{/orderLink}} %(customerString)s',
'woocommerce'
@ -175,6 +176,7 @@ function renderOrders( orders, customers, getFormattedOrderTotal ) {
<div>
<span>
{ sprintf(
/* translators: %d: number of products */
_n(
'%d product',
'%d products',

View File

@ -150,8 +150,9 @@ class ReviewsPanel extends Component {
const title = interpolateComponents( {
mixedString: sprintf(
/* translators: product reviewer as author, and product name */
__(
'{{authorLink}}%s{{/authorLink}}{{verifiedCustomerIcon/}} reviewed {{productLink}}%s{{/productLink}}',
'{{authorLink}}%1$s{{/authorLink}}{{verifiedCustomerIcon/}} reviewed {{productLink}}%2$s{{/productLink}}',
'woocommerce'
),
review.reviewer,

View File

@ -16,12 +16,14 @@ export const getNumberRangeString = (
) => {
if ( ! max ) {
return sprintf(
/* translators: a formatted number string, for the minimum value */
_x( '%s+', 'store product count or revenue', 'woocommerce' ),
formatAmount( numberConfig, min )
);
}
return sprintf(
/* translators: a formatted number string, for the minimum and maximum values */
_x(
'%1$s - %2$s',
'store product count or revenue range',

View File

@ -16,6 +16,7 @@ export const TermsOfService = ( { buttonText } ) => (
>
{ interpolateComponents( {
mixedString: sprintf(
/* translators: button text, most likely something like 'Install and Enable' or Continue setup' */
__(
'By clicking "%s," you agree to our {{tosLink}}Terms of Service{{/tosLink}} and have read our {{privacyPolicyLink}}Privacy Policy{{/privacyPolicyLink}}.',
'woocommerce'

View File

@ -118,6 +118,7 @@ export const Setup = ( { markConfigured, paymentGateway } ) => {
() => ( {
key: 'configure',
label: sprintf(
/* translators: %s = title of the payment gateway to install */
__( 'Configure your %(title)s account', 'woocommerce' ),
{
title,

View File

@ -29,6 +29,7 @@ export default function SetupNotice( { isSetupError, errorReason } ) {
: setupErrorDescriptions[ setupErrorTypes.SETUP ];
return sprintf(
/* translators: %s is the action from the setup error description above */
__(
'Unable to %s the plugin. Refresh the page and try again.',
'woocommerce'

View File

@ -197,6 +197,7 @@ export const AllCategoryList = forwardRef<
></span>
<span className="screen-reader-text">
{ sprintf(
/* translators: %s: category name */
__( 'Remove term: %s', 'woocommerce' ),
selectedCategory.name
) }

View File

@ -0,0 +1,4 @@
Significance: patch
Type: dev
Fixed some i18n related lint rule violations.

View File

@ -2,8 +2,6 @@ module.exports = {
extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ],
rules: {
// temporary conversion to warnings until the below are all handled.
'@wordpress/i18n-translator-comments': 'warn',
'@wordpress/valid-sprintf': 'warn',
'jsdoc/check-tag-names': [
'error',
{ definedTags: [ 'jest-environment' ] },