Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit b5d914c

Browse files
committed
fix translation quantities
1 parent b078c3b commit b5d914c

File tree

3 files changed

+96
-7
lines changed

3 files changed

+96
-7
lines changed

assets/js/atomic/components/product/button/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
import PropTypes from 'prop-types';
55
import classnames from 'classnames';
6-
import { __, sprintf } from '@wordpress/i18n';
6+
import { _n, sprintf } from '@wordpress/i18n';
77
import {
88
useMemo,
99
useCallback,
@@ -103,7 +103,12 @@ const ProductButton = ( { product, className } ) => {
103103
const getButtonText = () => {
104104
if ( Number.isFinite( cartQuantity ) && addedToCart ) {
105105
return sprintf(
106-
__( '%d in cart', 'woo-gutenberg-products-block' ),
106+
_n(
107+
'%d in cart',
108+
'%d in cart',
109+
cartQuantity,
110+
'woo-gutenberg-products-block'
111+
),
107112
cartQuantity
108113
);
109114
}

assets/js/base/components/checkbox-list/index.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* External dependencies
33
*/
4-
import { __, sprintf } from '@wordpress/i18n';
4+
import { __, _n, sprintf } from '@wordpress/i18n';
55
import PropTypes from 'prop-types';
66
import { Fragment, useMemo, useState } from '@wordpress/element';
77
import classNames from 'classnames';
@@ -48,17 +48,21 @@ const CheckboxList = ( {
4848
} }
4949
aria-expanded={ false }
5050
aria-label={ sprintf(
51-
__(
51+
_n(
52+
'Show %s more option',
5253
'Show %s more options',
54+
optionCount - limit,
5355
'woo-gutenberg-products-block'
5456
),
5557
optionCount - limit
5658
) }
5759
>
5860
{ // translators: %s number of options to reveal.
5961
sprintf(
60-
__(
62+
_n(
6163
'Show %s more',
64+
'Show %s more',
65+
optionCount - limit,
6266
'woo-gutenberg-products-block'
6367
),
6468
optionCount - limit
@@ -99,9 +103,9 @@ const CheckboxList = ( {
99103
{ options.map( ( option, index ) => (
100104
<Fragment key={ option.key }>
101105
<li
102-
{ ...shouldTruncateOptions &&
106+
{ ...( shouldTruncateOptions &&
103107
! showExpanded &&
104-
index >= limit && { hidden: true } }
108+
index >= limit && { hidden: true } ) }
105109
>
106110
<input
107111
type="checkbox"
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/**
2+
* External dependencies
3+
*/
4+
import classnames from 'classnames';
5+
import PropTypes from 'prop-types';
6+
import { __, sprintf } from '@wordpress/i18n';
7+
8+
/**
9+
* Internal dependencies
10+
*/
11+
import Label from '../../label';
12+
import './style.scss';
13+
14+
const StepNumber = ( { stepNumber } ) => {
15+
return (
16+
<div className="wc-components-checkout-step__number">
17+
<Label
18+
label={ stepNumber }
19+
screenReaderLabel={ sprintf(
20+
__(
21+
// translators: %s is a step number (1, 2, 3...)
22+
'Step %d',
23+
'woo-gutenberg-products-block'
24+
),
25+
stepNumber
26+
) }
27+
/>
28+
</div>
29+
);
30+
};
31+
32+
const StepHeading = ( { title, stepHeadingContent } ) => (
33+
<div className="wc-components-checkout-step__heading">
34+
<h4 className="wc-components-checkout-step__title">{ title }</h4>
35+
<span className="wc-components-checkout-step__heading-content">
36+
{ stepHeadingContent }
37+
</span>
38+
</div>
39+
);
40+
41+
const FormStep = ( {
42+
id,
43+
className,
44+
stepNumber,
45+
title,
46+
description,
47+
children,
48+
stepHeadingContent = () => null,
49+
} ) => {
50+
return (
51+
<div
52+
className={ classnames( className, 'wc-components-checkout-step' ) }
53+
id={ id }
54+
>
55+
<StepNumber stepNumber={ stepNumber } />
56+
<StepHeading
57+
title={ title }
58+
stepHeadingContent={ stepHeadingContent() }
59+
/>
60+
<span className="wc-components-checkout-step__description">
61+
{ description }
62+
</span>
63+
<div className="wc-components-checkout-step__content">
64+
{ children }
65+
</div>
66+
</div>
67+
);
68+
};
69+
70+
FormStep.propTypes = {
71+
id: PropTypes.string,
72+
className: PropTypes.string,
73+
stepNumber: PropTypes.number,
74+
title: PropTypes.string,
75+
description: PropTypes.string,
76+
children: PropTypes.node,
77+
stepHeadingContent: PropTypes.func,
78+
};
79+
80+
export default FormStep;

0 commit comments

Comments
 (0)