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

i18n: Relax sprintf arguments type #21919

Merged
merged 3 commits into from
Apr 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/i18n/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Master

### Bug Fix

- Relax type of `sprintf` arguments type ([#21919](https://github.com/WordPress/gutenberg/pull/21919))

## 3.11.0 (2020-04-15)

### New Features
Expand Down
2 changes: 1 addition & 1 deletion packages/i18n/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ _Related_
_Parameters_

- _format_ `string`: The format of the string to generate.
- _args_ `...string`: Arguments to apply to the format.
- _args_ `...*`: Arguments to apply to the format.

_Returns_

Expand Down
2 changes: 1 addition & 1 deletion packages/i18n/src/sprintf.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const logErrorOnce = memoize( console.error ); // eslint-disable-line no-console
* original format string is returned.
*
* @param {string} format The format of the string to generate.
* @param {...string} args Arguments to apply to the format.
* @param {...*} args Arguments to apply to the format.
*
* @see http://www.diveintojavascript.com/projects/javascript-sprintf
*
Expand Down
6 changes: 6 additions & 0 deletions packages/i18n/src/test/sprintf.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,11 @@ describe( 'i18n', () => {

expect( result ).toBe( 'bonjour Riad' );
} );

it( 'replaces named placeholders', () => {
const result = sprintf( 'bonjour %(name)s', { name: 'Riad' } );

expect( result ).toBe( 'bonjour Riad' );
} );
} );
} );