Skip to content

Commit

Permalink
Update percentage strings to be translatable (#66323)
Browse files Browse the repository at this point in the history
* Update percentage strings to be translatable

* Fix js lint errors

* Revert unexpected changes

* Add translation for button block

* Use integer instead of string placeholders

Co-authored-by: AhmarZaidi <[email protected]>
Co-authored-by: t-hamano <[email protected]>
  • Loading branch information
3 people authored Jan 3, 2025
1 parent 89de183 commit 8dd99ed
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
__experimentalToggleGroupControl as ToggleGroupControl,
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { __, sprintf } from '@wordpress/i18n';

/**
* Internal dependencies
Expand Down Expand Up @@ -137,7 +137,11 @@ export default function ImageSizeControl( {
<ToggleGroupControlOption
key={ scale }
value={ scale }
label={ `${ scale }%` }
label={ sprintf(
/* translators: Percentage value. */
__( '%1$d%%' ),
scale
) }
/>
);
} ) }
Expand Down
8 changes: 6 additions & 2 deletions packages/block-library/src/button/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { __, sprintf } from '@wordpress/i18n';
import { useEffect, useState, useRef, useMemo } from '@wordpress/element';
import {
TextControl,
Expand Down Expand Up @@ -148,7 +148,11 @@ function WidthPanel( { selectedWidth, setAttributes } ) {
<ToggleGroupControlOption
key={ widthValue }
value={ widthValue }
label={ `${ widthValue }%` }
label={ sprintf(
/* translators: Percentage value. */
__( '%1$d%%' ),
widthValue
) }
/>
);
} ) }
Expand Down
8 changes: 6 additions & 2 deletions packages/block-library/src/search/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
} from '@wordpress/components';
import { useInstanceId } from '@wordpress/compose';
import { Icon, search } from '@wordpress/icons';
import { __ } from '@wordpress/i18n';
import { __, sprintf } from '@wordpress/i18n';
import { __unstableStripHTML as stripHTML } from '@wordpress/dom';

/**
Expand Down Expand Up @@ -470,7 +470,11 @@ export default function SearchEdit( {
<ToggleGroupControlOption
key={ widthValue }
value={ widthValue }
label={ `${ widthValue }%` }
label={ sprintf(
/* translators: Percentage value. */
__( '%1$d%%' ),
widthValue
) }
/>
);
} ) }
Expand Down

0 comments on commit 8dd99ed

Please sign in to comment.