Customize: Improve i18n for strings in hidden widget area notices.

Amends [40312].
Props westonruter, ocean90, swissspidy, SergeyBiryukov, michelleweber for copywriting.
See #33567, #33052.
Fixes #39087.


git-svn-id: https://develop.svn.wordpress.org/trunk@40330 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
westonruter 2017-03-24 22:02:02 +00:00
parent 54baae39b2
commit 1e7b157523
3 changed files with 54 additions and 28 deletions

View File

@ -1616,7 +1616,7 @@
* @returns {void}
*/
updateNotice = function() {
var activeSectionCount = getActiveSectionCount(), message, nonRenderedAreaCount, registeredAreaCount;
var activeSectionCount = getActiveSectionCount(), someRenderedMessage, nonRenderedAreaCount, registeredAreaCount;
noticeContainer.empty();
registeredAreaCount = api.Widgets.data.registeredSidebars.length;
@ -1624,14 +1624,16 @@
if ( 0 !== activeSectionCount ) {
nonRenderedAreaCount = registeredAreaCount - activeSectionCount;
message = ( 1 === nonRenderedAreaCount ? l10n.someAreasShown.singular : l10n.someAreasShown.plural ).replace( '%d', nonRenderedAreaCount );
someRenderedMessage = l10n.someAreasShown[ nonRenderedAreaCount ];
} else {
message = ( 1 === registeredAreaCount ? l10n.noAreasShown.singular : l10n.noAreasShown.plural ).replace( '%d', registeredAreaCount );
someRenderedMessage = l10n.noAreasShown;
}
if ( someRenderedMessage ) {
noticeContainer.append( $( '<p></p>', {
text: someRenderedMessage
} ) );
}
noticeContainer.append( $( '<p></p>', {
text: message
} ) );
noticeContainer.append( $( '<p></p>', {
text: l10n.navigatePreview
} ) );

View File

@ -720,6 +720,47 @@ final class WP_Customize_Widgets {
</div>'
);
/*
* Gather all strings in PHP that may be needed by JS on the client.
* Once JS i18n is implemented (in #20491), this can be removed.
*/
$some_non_rendered_areas_messages = array();
$some_non_rendered_areas_messages[1] = html_entity_decode(
/* translators: placeholder is the number of other widget areas registered but not rendered */
__( 'Your theme has 1 other widget area, but this particular page doesn&#8217;t display it.' ),
ENT_QUOTES,
get_bloginfo( 'charset' )
);
$registered_sidebar_count = count( $wp_registered_sidebars );
for ( $non_rendered_count = 2; $non_rendered_count < $registered_sidebar_count; $non_rendered_count++ ) {
$some_non_rendered_areas_messages[ $non_rendered_count ] = html_entity_decode( sprintf(
/* translators: placeholder is the number of other widget areas registered but not rendered */
_n(
'Your theme has %s other widget area, but this particular page doesn&#8217;t display it.',
'Your theme has %s other widget areas, but this particular page doesn&#8217;t display them.',
$non_rendered_count
),
number_format_i18n( $non_rendered_count )
), ENT_QUOTES, get_bloginfo( 'charset' ) );
}
if ( 1 === $registered_sidebar_count ) {
$no_areas_shown_message = html_entity_decode( sprintf(
/* translators: placeholder is the total number of widget areas registered */
__( 'Your theme has 1 widget area, but this particular page doesn&#8217;t display it.' )
), ENT_QUOTES, get_bloginfo( 'charset' ) );
} else {
$no_areas_shown_message = html_entity_decode( sprintf(
/* translators: placeholder is the total number of widget areas registered */
_n(
'Your theme has %s widget area, but this particular page doesn&#8217;t display it.',
'Your theme has %s widget areas, but this particular page doesn&#8217;t display them.',
$registered_sidebar_count
),
number_format_i18n( $registered_sidebar_count )
), ENT_QUOTES, get_bloginfo( 'charset' ) );
}
$settings = array(
'registeredSidebars' => array_values( $wp_registered_sidebars ),
'registeredWidgets' => $wp_registered_widgets,
@ -733,22 +774,8 @@ final class WP_Customize_Widgets {
'widgetMovedUp' => __( 'Widget moved up' ),
'widgetMovedDown' => __( 'Widget moved down' ),
'navigatePreview' => __( 'You can navigate to other pages on your site while using the Customizer to view and edit the widgets displayed on those pages.' ),
'someAreasShown' => wp_array_slice_assoc(
/* translators: placeholder is the number of other widget areas registered */
_n_noop(
'Your theme has %d other widget area, but this particular page doesn\'t display it.',
'Your theme has %d other widget areas, but this particular page doesn\'t display them.'
),
array( 'singular', 'plural' )
),
'noAreasShown' => wp_array_slice_assoc(
/* translators: placeholder is the total number of widget areas registered */
_n_noop(
'Your theme has %d widget area, but this particular page doesn\'t display it.',
'Your theme has %d widget areas, but this particular page doesn\'t display them.'
),
array( 'singular', 'plural' )
),
'someAreasShown' => $some_non_rendered_areas_messages,
'noAreasShown' => $no_areas_shown_message,
'reorderModeOn' => __( 'Reorder mode enabled' ),
'reorderModeOff' => __( 'Reorder mode closed' ),
'reorderLabelOn' => esc_attr__( 'Reorder widgets' ),

View File

@ -48,10 +48,7 @@ window._wpCustomizeWidgetsSettings = {
'l10n': {
'error': 'An error has occurred. Please reload the page and try again.',
'navigatePreview': 'You can navigate to other pages on your site while using the Customizer to view and edit the widgets displayed on those pages.',
'noAreasShown': {
'plural': 'Your theme has %d widget areas, but this particular page doesn\'t display them.',
'singular': 'Your theme has %d widget area, but this particular page doesn\'t display it.'
},
'noAreasShown': 'Your theme has 3 widget areas, but this particular page doesn\u2019t display them.',
'noWidgetsFound': 'No widgets found.',
'removeBtnLabel': 'Remove',
'removeBtnTooltip': 'Trash widget by moving it to the inactive widgets sidebar.',
@ -61,8 +58,8 @@ window._wpCustomizeWidgetsSettings = {
'saveBtnLabel': 'Apply',
'saveBtnTooltip': 'Save and preview changes before publishing them.',
'someAreasShown': {
'plural': 'Your theme has %d other widget areas, but this particular page doesn\'t display them.',
'singular': 'Your theme has %d other widget area, but this particular page doesn\'t display it.'
'1': 'Your theme has 1 other widget area, but this particular page doesn\u2019t display it.',
'2': 'Your theme has 2 other widget areas, but this particular page doesn\u2019t display them.'
},
'widgetMovedDown': 'Widget moved down',
'widgetMovedUp': 'Widget moved up',