From 4e320fe0087e8df83e6ba7f7765dbc7100c20067 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Mon, 13 Nov 2017 07:08:47 +0000 Subject: [PATCH] I18N: Fix passing singular/plural strings to JS. This is a temporary solution while waiting for full I18N support in JS. Props ocean90, dd32, westonruter, Mirucon for testing. Amends [41376], [41721], [41389], See #20491. Fixes #42510 for trunk. Built from https://develop.svn.wordpress.org/trunk@42163 git-svn-id: http://core.svn.wordpress.org/trunk@41994 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/script-loader.php | 21 +++++++++++-------- wp-includes/version.php | 2 +- .../widgets/class-wp-widget-custom-html.php | 7 ++++--- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index e5204a7aa0..cc401f6925 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -476,10 +476,11 @@ function wp_default_scripts( &$scripts ) { did_action( 'init' ) && $scripts->add_inline_script( 'wp-theme-plugin-editor', sprintf( 'wp.themePluginEditor.l10n = %s;', wp_json_encode( array( 'saveAlert' => __( 'The changes you made will be lost if you navigate away from this page.' ), 'saveError' => __( 'Something went wrong. Your change may not have been saved. Please try again. There is also a chance that you may need to manually fix and upload the file over FTP.' ), - 'lintError' => wp_array_slice_assoc( + 'lintError' => array( /* translators: %d: error count */ - _n_noop( 'There is %d error which must be fixed before you can update this file.', 'There are %d errors which must be fixed before you can update this file.' ), - array( 'singular', 'plural' ) + 'singular' => _n( 'There is %d error which must be fixed before you can update this file.', 'There are %d errors which must be fixed before you can update this file.', 1 ), + /* translators: %d: error count */ + 'plural' => _n( 'There is %d error which must be fixed before you can update this file.', 'There are %d errors which must be fixed before you can update this file.', 2 ), // @todo This is lacking, as some languages have a dedicated dual form. For proper handling of plurals in JS, see #20491. ), ) ) ) ); @@ -580,16 +581,18 @@ function wp_default_scripts( &$scripts ) { 'videoHeaderNotice' => __( 'This theme doesn’t support video headers on this page. Navigate to the front page or another page that supports video headers.' ), // Used for overriding the file types allowed in plupload. 'allowedFiles' => __( 'Allowed Files' ), - 'customCssError' => wp_array_slice_assoc( + 'customCssError' => array( /* translators: %d: error count */ - _n_noop( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.' ), - array( 'singular', 'plural' ) + 'singular' => _n( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.', 1 ), + /* translators: %d: error count */ + 'plural' => _n( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.', 2 ), // @todo This is lacking, as some languages have a dedicated dual form. For proper handling of plurals in JS, see #20491. ), 'pageOnFrontError' => __( 'Homepage and posts page must be different.' ), - 'saveBlockedError' => wp_array_slice_assoc( + 'saveBlockedError' => array( /* translators: %s: number of invalid settings */ - _n_noop( 'Unable to save due to %s invalid setting.', 'Unable to save due to %s invalid settings.' ), - array( 'singular', 'plural' ) + 'singular' => _n( 'Unable to save due to %s invalid setting.', 'Unable to save due to %s invalid settings.', 1 ), + /* translators: %s: number of invalid settings */ + 'plural' => _n( 'Unable to save due to %s invalid setting.', 'Unable to save due to %s invalid settings.', 2 ), // @todo This is lacking, as some languages have a dedicated dual form. For proper handling of plurals in JS, see #20491. ), 'scheduleDescription' => __( 'Schedule your customization changes to publish ("go live") at a future date.' ), 'themePreviewUnavailable' => __( 'Sorry, you can’t preview new themes when you have changes scheduled or saved as a draft. Please publish your changes, or wait until they publish to preview new themes.' ), diff --git a/wp-includes/version.php b/wp-includes/version.php index 38948f9075..a211a2df9b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '5.0-alpha-42161'; +$wp_version = '5.0-alpha-42163'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. diff --git a/wp-includes/widgets/class-wp-widget-custom-html.php b/wp-includes/widgets/class-wp-widget-custom-html.php index a75e264479..855c3c5895 100644 --- a/wp-includes/widgets/class-wp-widget-custom-html.php +++ b/wp-includes/widgets/class-wp-widget-custom-html.php @@ -175,10 +175,11 @@ class WP_Widget_Custom_HTML extends WP_Widget { wp_add_inline_script( 'custom-html-widgets', sprintf( 'wp.customHtmlWidgets.init( %s );', wp_json_encode( $settings ) ), 'after' ); $l10n = array( - 'errorNotice' => wp_array_slice_assoc( + 'errorNotice' => array( /* translators: %d: error count */ - _n_noop( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.' ), - array( 'singular', 'plural' ) + 'singular' => _n( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.', 1 ), + /* translators: %d: error count */ + 'plural' => _n( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.', 2 ), // @todo This is lacking, as some languages have a dedicated dual form. For proper handling of plurals in JS, see #20491. ), ); wp_add_inline_script( 'custom-html-widgets', sprintf( 'jQuery.extend( wp.customHtmlWidgets.l10n, %s );', wp_json_encode( $l10n ) ), 'after' );