From c66edd0439a8294e03389b4907a126c1e5f9374d Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 7 Nov 2020 21:59:11 +0000 Subject: [PATCH] REST API: Use `_n()` in some error messages for proper plural forms support. Follow-up to [47923], [49053]. Props audrasjb, tobifjellner, TimothyBlynJacobs, SergeyBiryukov. Fixes #51727. Built from https://develop.svn.wordpress.org/trunk@49536 git-svn-id: http://core.svn.wordpress.org/trunk@49274 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/rest-api.php | 60 ++++++++++++++++++++++++++++++++++------ wp-includes/version.php | 2 +- 2 files changed, 53 insertions(+), 9 deletions(-) diff --git a/wp-includes/rest-api.php b/wp-includes/rest-api.php index 1c507e0524..870bc6443c 100644 --- a/wp-includes/rest-api.php +++ b/wp-includes/rest-api.php @@ -2009,13 +2009,35 @@ function rest_validate_value_from_schema( $value, $args, $param = '' ) { } if ( isset( $args['minItems'] ) && count( $value ) < $args['minItems'] ) { - /* translators: 1: Parameter, 2: Number. */ - return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must contain at least %2$s items.' ), $param, number_format_i18n( $args['minItems'] ) ) ); + return new WP_Error( + 'rest_invalid_param', + sprintf( + /* translators: 1: Parameter, 2: Number. */ + _n( + '%1$s must contain at least %2$s item.', + '%1$s must contain at least %2$s items.', + $args['minItems'] + ), + $param, + number_format_i18n( $args['minItems'] ) + ) + ); } if ( isset( $args['maxItems'] ) && count( $value ) > $args['maxItems'] ) { - /* translators: 1: Parameter, 2: Number. */ - return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must contain at most %2$s items.' ), $param, number_format_i18n( $args['maxItems'] ) ) ); + return new WP_Error( + 'rest_invalid_param', + sprintf( + /* translators: 1: Parameter, 2: Number. */ + _n( + '%1$s must contain at most %2$s item.', + '%1$s must contain at most %2$s items.', + $args['maxItems'] + ), + $param, + number_format_i18n( $args['maxItems'] ) + ) + ); } if ( ! empty( $args['uniqueItems'] ) && ! rest_validate_array_contains_unique_items( $value ) ) { @@ -2086,13 +2108,35 @@ function rest_validate_value_from_schema( $value, $args, $param = '' ) { } if ( isset( $args['minProperties'] ) && count( $value ) < $args['minProperties'] ) { - /* translators: 1: Parameter, 2: Number. */ - return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must contain at least %2$s properties.' ), $param, number_format_i18n( $args['minProperties'] ) ) ); + return new WP_Error( + 'rest_invalid_param', + sprintf( + /* translators: 1: Parameter, 2: Number. */ + _n( + '%1$s must contain at least %2$s property.', + '%1$s must contain at least %2$s properties.', + $args['minProperties'] + ), + $param, + number_format_i18n( $args['minProperties'] ) + ) + ); } if ( isset( $args['maxProperties'] ) && count( $value ) > $args['maxProperties'] ) { - /* translators: 1: Parameter, 2: Number. */ - return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must contain at most %2$s properties.' ), $param, number_format_i18n( $args['maxProperties'] ) ) ); + return new WP_Error( + 'rest_invalid_param', + sprintf( + /* translators: 1: Parameter, 2: Number. */ + _n( + '%1$s must contain at most %2$s property.', + '%1$s must contain at most %2$s properties.', + $args['maxProperties'] + ), + $param, + number_format_i18n( $args['maxProperties'] ) + ) + ); } } diff --git a/wp-includes/version.php b/wp-includes/version.php index 5aa0aba772..d72219dedf 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.6-beta3-49535'; +$wp_version = '5.6-beta3-49536'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.