WordPress.org

Make WordPress Core

Changeset 40330


Ignore:
Timestamp:
03/24/17 22:02:02 (5 months ago)
Author:
westonruter
Message:

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.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/customize-widgets.js

    r40312 r40330  
    16171617                 */ 
    16181618                updateNotice = function() { 
    1619                     var activeSectionCount = getActiveSectionCount(), message, nonRenderedAreaCount, registeredAreaCount; 
     1619                    var activeSectionCount = getActiveSectionCount(), someRenderedMessage, nonRenderedAreaCount, registeredAreaCount; 
    16201620                    noticeContainer.empty(); 
    16211621 
     
    16251625                        if ( 0 !== activeSectionCount ) { 
    16261626                            nonRenderedAreaCount = registeredAreaCount - activeSectionCount; 
    1627                             message = ( 1 === nonRenderedAreaCount ? l10n.someAreasShown.singular : l10n.someAreasShown.plural ).replace( '%d', nonRenderedAreaCount ); 
     1627                            someRenderedMessage = l10n.someAreasShown[ nonRenderedAreaCount ]; 
    16281628                        } else { 
    1629                             message = ( 1 === registeredAreaCount ? l10n.noAreasShown.singular : l10n.noAreasShown.plural ).replace( '%d', registeredAreaCount ); 
     1629                            someRenderedMessage = l10n.noAreasShown; 
    16301630                        } 
    1631  
    1632                         noticeContainer.append( $( '<p></p>', { 
    1633                             text: message 
    1634                         } ) ); 
     1631                        if ( someRenderedMessage ) { 
     1632                            noticeContainer.append( $( '<p></p>', { 
     1633                                text: someRenderedMessage 
     1634                            } ) ); 
     1635                        } 
     1636 
    16351637                        noticeContainer.append( $( '<p></p>', { 
    16361638                            text: l10n.navigatePreview 
  • trunk/src/wp-includes/class-wp-customize-widgets.php

    r40312 r40330  
    721721        ); 
    722722 
     723        /* 
     724         * Gather all strings in PHP that may be needed by JS on the client. 
     725         * Once JS i18n is implemented (in #20491), this can be removed. 
     726         */ 
     727        $some_non_rendered_areas_messages = array(); 
     728        $some_non_rendered_areas_messages[1] = html_entity_decode( 
     729            /* translators: placeholder is the number of other widget areas registered but not rendered */ 
     730            __( 'Your theme has 1 other widget area, but this particular page doesn&#8217;t display it.' ), 
     731            ENT_QUOTES, 
     732            get_bloginfo( 'charset' ) 
     733        ); 
     734        $registered_sidebar_count = count( $wp_registered_sidebars ); 
     735        for ( $non_rendered_count = 2; $non_rendered_count < $registered_sidebar_count; $non_rendered_count++ ) { 
     736            $some_non_rendered_areas_messages[ $non_rendered_count ] = html_entity_decode( sprintf( 
     737                /* translators: placeholder is the number of other widget areas registered but not rendered */ 
     738                _n( 
     739                    'Your theme has %s other widget area, but this particular page doesn&#8217;t display it.', 
     740                    'Your theme has %s other widget areas, but this particular page doesn&#8217;t display them.', 
     741                    $non_rendered_count 
     742                ), 
     743                number_format_i18n( $non_rendered_count ) 
     744            ), ENT_QUOTES, get_bloginfo( 'charset' ) ); 
     745        } 
     746 
     747        if ( 1 === $registered_sidebar_count ) { 
     748            $no_areas_shown_message = html_entity_decode( sprintf( 
     749                /* translators: placeholder is the total number of widget areas registered */ 
     750                __( 'Your theme has 1 widget area, but this particular page doesn&#8217;t display it.' ) 
     751            ), ENT_QUOTES, get_bloginfo( 'charset' ) ); 
     752        } else { 
     753            $no_areas_shown_message = html_entity_decode( sprintf( 
     754                /* translators: placeholder is the total number of widget areas registered */ 
     755                _n( 
     756                    'Your theme has %s widget area, but this particular page doesn&#8217;t display it.', 
     757                    'Your theme has %s widget areas, but this particular page doesn&#8217;t display them.', 
     758                    $registered_sidebar_count 
     759                ), 
     760                number_format_i18n( $registered_sidebar_count ) 
     761            ), ENT_QUOTES, get_bloginfo( 'charset' ) ); 
     762        } 
     763 
    723764        $settings = array( 
    724765            'registeredSidebars'   => array_values( $wp_registered_sidebars ), 
     
    734775                'widgetMovedDown'  => __( 'Widget moved down' ), 
    735776                'navigatePreview'  => __( 'You can navigate to other pages on your site while using the Customizer to view and edit the widgets displayed on those pages.' ), 
    736                 'someAreasShown'   => wp_array_slice_assoc( 
    737                     /* translators: placeholder is the number of other widget areas registered */ 
    738                     _n_noop( 
    739                         'Your theme has %d other widget area, but this particular page doesn\'t display it.', 
    740                         'Your theme has %d other widget areas, but this particular page doesn\'t display them.' 
    741                     ), 
    742                     array( 'singular', 'plural' ) 
    743                 ), 
    744                 'noAreasShown'    => wp_array_slice_assoc( 
    745                     /* translators: placeholder is the total number of widget areas registered */ 
    746                     _n_noop( 
    747                         'Your theme has %d widget area, but this particular page doesn\'t display it.', 
    748                         'Your theme has %d widget areas, but this particular page doesn\'t display them.' 
    749                     ), 
    750                     array( 'singular', 'plural' ) 
    751                 ), 
     777                'someAreasShown'   => $some_non_rendered_areas_messages, 
     778                'noAreasShown'     => $no_areas_shown_message, 
    752779                'reorderModeOn'    => __( 'Reorder mode enabled' ), 
    753780                'reorderModeOff'   => __( 'Reorder mode closed' ), 
  • trunk/tests/qunit/fixtures/customize-widgets.js

    r40312 r40330  
    4949        'error': 'An error has occurred. Please reload the page and try again.', 
    5050        'navigatePreview': 'You can navigate to other pages on your site while using the Customizer to view and edit the widgets displayed on those pages.', 
    51         'noAreasShown': { 
    52             'plural': 'Your theme has %d widget areas, but this particular page doesn\'t display them.', 
    53             'singular': 'Your theme has %d widget area, but this particular page doesn\'t display it.' 
    54         }, 
     51        'noAreasShown': 'Your theme has 3 widget areas, but this particular page doesn\u2019t display them.', 
    5552        'noWidgetsFound': 'No widgets found.', 
    5653        'removeBtnLabel': 'Remove', 
     
    6259        'saveBtnTooltip': 'Save and preview changes before publishing them.', 
    6360        'someAreasShown': { 
    64             'plural': 'Your theme has %d other widget areas, but this particular page doesn\'t display them.', 
    65             'singular': 'Your theme has %d other widget area, but this particular page doesn\'t display it.' 
     61            '1': 'Your theme has 1 other widget area, but this particular page doesn\u2019t display it.', 
     62            '2': 'Your theme has 2 other widget areas, but this particular page doesn\u2019t display them.' 
    6663        }, 
    6764        'widgetMovedDown': 'Widget moved down', 
Note: See TracChangeset for help on using the changeset viewer.