Make WordPress Core

Changeset 38057


Ignore:
Timestamp:
07/13/2016 05:31:15 PM (10 years ago)
Author:
ocean90
Message:

Update/Install: Give context to some install/update strings to allow for differentiation between theme and plugin translations.

Props swissspidy, SergeyBiryukov.
Fixes #37290.

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/ajax-actions.php

    r38033 r38057  
    33453345        }
    33463346
     3347        $status['themeName'] = wp_get_theme( $slug )->get( 'Name' );
     3348
    33473349        if ( current_user_can( 'switch_themes' ) ) {
    33483350                if ( is_multisite() ) {
  • trunk/src/wp-admin/includes/theme.php

    r38025 r38057  
    636636                                <div class="theme-actions">
    637637                                        <div class="inactive-theme">
    638                                                 <a href="<?php echo $preview_url; ?>" target="_top" class="button button-primary"><?php _e( 'Live Preview' ); ?></a>
     638                                                <?php
     639                                                /* translators: %s: Theme name */
     640                                                $aria_label = sprintf( __( 'Preview %s' ), '{{ data.name }}' );
     641                                                ?>
     642                                                <a href="<?php echo $preview_url; ?>" target="_top" class="button button-primary" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Live Preview' ); ?></a>
    639643                                        </div>
    640644                                </div>
  • trunk/src/wp-admin/includes/update.php

    r37714 r38057  
    691691 *         @type string content The row content.
    692692 *     }
    693  *             
     693 *
    694694 * The delete template takes one argument with four values:
    695695 *
    … …  
    717717                <tr class="plugin-deleted-tr inactive deleted" id="{{ data.slug }}-deleted" data-slug="{{ data.slug }}" <# if ( data.plugin ) { #>data-plugin="{{ data.plugin }}"<# } #>>
    718718                        <td colspan="{{ data.colspan }}" class="plugin-update colspanchange">
    719                                 <?php
    720                                 printf(
    721                                         /* translators: %s: Plugin or Theme name */
    722                                         __( '%s was successfully deleted.' ),
    723                                         '<strong>{{{ data.name }}}</strong>'
    724                                 );
    725                                 ?>
     719                                <# if ( data.plugin ) { #>
     720                                        <?php
     721                                        printf(
     722                                                /* translators: %s: Plugin name */
     723                                                _x( '%s was successfully deleted.', 'plugin' ),
     724                                                '<strong>{{{ data.name }}}</strong>'
     725                                        );
     726                                        ?>
     727                                <# } else { #>
     728                                        <?php
     729                                        printf(
     730                                                /* translators: %s: Theme name */
     731                                                _x( '%s was successfully deleted.', 'theme' ),
     732                                                '<strong>{{{ data.name }}}</strong>'
     733                                        );
     734                                        ?>
     735                                <# } #>
    726736                        </td>
    727737                </tr>
  • trunk/src/wp-admin/js/updates.js

    r38033 r38057  
    509509                }
    510510
    511                 $message.addClass( 'updating-message' );
     511                $message
     512                        .addClass( 'updating-message' )
     513                        .attr( 'aria-label', wp.updates.l10n.pluginInstallingLabel.replace( '%s', $message.data( 'name' ) ) );
    512514
    513515                wp.a11y.speak( wp.updates.l10n.installingMsg, 'polite' );
    … …  
    536538                        .removeClass( 'updating-message' )
    537539                        .addClass( 'updated-message installed button-disabled' )
     540                        .attr( 'aria-label', wp.updates.l10n.pluginInstalledLabel.replace( '%s', response.pluginName ) )
    538541                        .text( wp.updates.l10n.installed );
    539542
    … …  
    548551                                $message.removeClass( 'install-now installed button-disabled updated-message' ).addClass( 'activate-now button-primary' )
    549552                                        .attr( 'href', response.activateUrl )
     553                                        .attr( 'aria-label', wp.updates.l10n.activatePluginLabel.replace( '%s', response.pluginName ) )
    550554                                        .text( wp.updates.l10n.activatePlugin );
    551555                        }, 1000 );
    … …  
    596600                $button
    597601                        .removeClass( 'updating-message' ).addClass( 'button-disabled' )
    598                         .attr( 'aria-label', wp.updates.l10n.installFailedLabel.replace( '%s', response.pluginName ) )
     602                        .attr( 'aria-label', wp.updates.l10n.pluginInstallFailedLabel.replace( '%s', $button.data( 'name' ) ) )
    599603                        .text( wp.updates.l10n.installFailedShort );
    600604
    … …  
    10041008                }
    10051009
    1006                 $message.text( wp.updates.l10n.installing );
     1010                $message
     1011                        .text( wp.updates.l10n.installing )
     1012                        .attr( 'aria-label', wp.updates.l10n.themeInstallingLabel.replace( '%s', $message.data( 'name' ) ) );
    10071013                wp.a11y.speak( wp.updates.l10n.installingMsg, 'polite' );
    10081014
    … …  
    10331039                        .removeClass( 'updating-message' )
    10341040                        .addClass( 'updated-message disabled' )
     1041                        .attr( 'aria-label', wp.updates.l10n.themeInstalledLabel.replace( '%s', response.themeName ) )
    10351042                        .text( wp.updates.l10n.installed );
    10361043
    … …  
    10461053                                        .removeClass( 'theme-install updated-message disabled' )
    10471054                                        .addClass( 'activate' )
     1055                                        .attr( 'aria-label', wp.updates.l10n.activateThemeLabel.replace( '%s', response.themeName ) )
    10481056                                        .text( wp.updates.l10n.activateTheme );
    10491057                        }
    … …  
    10991107                $button
    11001108                        .removeClass( 'updating-message' )
    1101                         .attr( 'aria-label', wp.updates.l10n.installFailedLabel.replace( '%s', $card.find( '.theme-name' ).text() ) )
     1109                        .attr( 'aria-label', wp.updates.l10n.themeInstallFailedLabel.replace( '%s', $button.data( 'name' ) ) )
    11021110                        .text( wp.updates.l10n.installFailedShort );
    11031111
  • trunk/src/wp-admin/theme-install.php

    r37914 r38057  
    249249        <div class="theme-actions">
    250250                <# if ( data.installed ) { #>
     251                        <?php
     252                        /* translators: %s: Theme name */
     253                        $aria_label = sprintf( __( 'Activate %s' ), '{{ data.name }}' );
     254                        ?>
    251255                        <# if ( data.activate_url ) { #>
    252                                 <a class="button button-primary activate" href="{{ data.activate_url }}"><?php esc_html_e( 'Activate' ); ?></a>
     256                                <a class="button button-primary activate" href="{{ data.activate_url }}" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a>
    253257                        <# } #>
    254258                        <# if ( data.customize_url ) { #>
    255                                 <a class="button button-secondary load-customize" href="{{ data.customize_url }}"><?php esc_html_e( 'Live Preview' ); ?></a>
     259                                <a class="button button-secondary load-customize" href="{{ data.customize_url }}"><?php _e( 'Live Preview' ); ?></a>
    256260                        <# } else { #>
    257                                 <button class="button-secondary preview install-theme-preview"><?php esc_html_e( 'Preview' ); ?></button>
     261                                <button class="button-secondary preview install-theme-preview"><?php _e( 'Preview' ); ?></button>
    258262                        <# } #>
    259263                <# } else { #>
    260                         <a class="button button-primary theme-install" data-slug="{{ data.id }}" href="{{ data.install_url }}"><?php esc_html_e( 'Install' ); ?></a>
    261                         <button class="button-secondary preview install-theme-preview"><?php esc_html_e( 'Preview' ); ?></button>
     264                        <?php
     265                        /* translators: %s: Theme name */
     266                        $aria_label = sprintf( __( 'Install %s' ), '{{ data.name }}' );
     267                        ?>
     268                        <a class="button button-primary theme-install" data-name="{{ data.name }}" data-slug="{{ data.id }}" href="{{ data.install_url }}" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Install' ); ?></a>
     269                        <button class="button-secondary preview install-theme-preview"><?php _e( 'Preview' ); ?></button>
    262270                <# } #>
    263271        </div>
    … …  
    275283                        <button class="next-theme"><span class="screen-reader-text"><?php _ex( 'Next', 'Button label for a theme' ); ?></span></button>
    276284                        <# if ( data.installed ) { #>
    277                                 <a class="button button-primary activate" href="{{ data.activate_url }}"><?php esc_html_e( 'Activate' ); ?></a>
     285                                <a class="button button-primary activate" href="{{ data.activate_url }}"><?php _e( 'Activate' ); ?></a>
    278286                        <# } else { #>
    279                                 <a href="{{ data.install_url }}" class="button button-primary theme-install" data-slug="{{ data.id }}"><?php _e( 'Install' ); ?></a>
     287                                <a href="{{ data.install_url }}" class="button button-primary theme-install" data-name="{{ data.name }}" data-slug="{{ data.id }}"><?php _e( 'Install' ); ?></a>
    280288                        <# } #>
    281289                </div>
  • trunk/src/wp-admin/themes.php

    r37914 r38057  
    278278                <?php } ?>
    279279        <?php } else { ?>
    280                 <a class="button button-secondary activate" href="<?php echo $theme['actions']['activate']; ?>"><?php _e( 'Activate' ); ?></a>
     280                <?php
     281                /* translators: %s: Theme name */
     282                $aria_label = sprintf( __( 'Activate %s' ), '{{ data.name }}' );
     283                ?>
     284                <a class="button button-secondary activate" href="<?php echo $theme['actions']['activate']; ?>" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a>
    281285                <?php if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?>
    282286                        <a class="button button-primary load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Live Preview' ); ?></a>
    … …  
    403407                        <# } #>
    404408                <# } else { #>
    405                         <a class="button button-secondary activate" href="{{{ data.actions.activate }}}"><?php _e( 'Activate' ); ?></a>
     409                        <?php
     410                        /* translators: %s: Theme name */
     411                        $aria_label = sprintf( __( 'Activate %s' ), '{{ data.name }}' );
     412                        ?>
     413                        <a class="button button-secondary activate" href="{{{ data.actions.activate }}}" aria-label="<?php echo $aria_label; ?>"><?php _e( 'Activate' ); ?></a>
    406414                        <a class="button button-primary load-customize hide-if-no-customize" href="{{{ data.actions.customize }}}"><?php _e( 'Live Preview' ); ?></a>
    407415                <# } #>
    … …  
    457465                        </div>
    458466                        <div class="inactive-theme">
     467                                <?php
     468                                /* translators: %s: Theme name */
     469                                $aria_label = sprintf( __( 'Activate %s' ), '{{ data.name }}' );
     470                                ?>
    459471                                <# if ( data.actions.activate ) { #>
    460                                         <a href="{{{ data.actions.activate }}}" class="button button-secondary activate"><?php _e( 'Activate' ); ?></a>
     472                                        <a href="{{{ data.actions.activate }}}" class="button button-secondary activate" aria-label="<?php echo $aria_label; ?>"><?php _e( 'Activate' ); ?></a>
    461473                                <# } #>
    462474                                <a href="{{{ data.actions.customize }}}" class="button button-primary load-customize hide-if-no-customize"><?php _e( 'Live Preview' ); ?></a>
  • trunk/src/wp-includes/script-loader.php

    r38033 r38057  
    629629                                /* translators: Error string for a failed installation */
    630630                                'installFailed'              => __( 'Installation failed: %s' ),
    631                                 /* translators: Plugin/Theme name and version */
    632                                 'installingLabel'            => __( 'Installing %s...' ), // no ellipsis
    633                                 /* translators: Plugin/Theme name and version */
    634                                 'installedLabel'             => __( '%s installed!' ),
    635                                 /* translators: Plugin/Theme name and version */
    636                                 'installFailedLabel'         => __( '%s installation failed' ),
     631                                /* translators: Plugin name and version */
     632                                'pluginInstallingLabel'      => _x( 'Installing %s...', 'plugin' ), // no ellipsis
     633                                /* translators: Theme name and version */
     634                                'themeInstallingLabel'       => _x( 'Installing %s...', 'theme' ), // no ellipsis
     635                                /* translators: Plugin name and version */
     636                                'pluginInstalledLabel'       => _x( '%s installed!', 'plugin' ),
     637                                /* translators: Theme name and version */
     638                                'themeInstalledLabel'        => _x( '%s installed!', 'theme' ),
     639                                /* translators: Plugin name and version */
     640                                'pluginInstallFailedLabel'   => _x( '%s installation failed', 'plugin' ),
     641                                /* translators: Theme name and version */
     642                                'themeInstallFailedLabel'    => _x( '%s installation failed', 'theme' ),
    637643                                'installingMsg'              => __( 'Installing... please wait.' ),
    638644                                'installedMsg'               => __( 'Installation completed successfully.' ),
    … …  
    650656                                'deleted'                    => __( 'Deleted!' ),
    651657                                'livePreview'                => __( 'Live Preview' ),
     658                                /* translators: %s: Theme name */
    652659                                'activatePlugin'             => is_network_admin() ? __( 'Network Activate' ) : __( 'Activate' ),
    653660                                'activateTheme'              => is_network_admin() ? __( 'Network Enable' ) : __( 'Activate' ),
     661                                /* translators: %s: Plugin name */
     662                                'activatePluginLabel'        => is_network_admin() ? _x( 'Network Activate %s', 'plugin' ) : _x( 'Activate %s', 'plugin' ),
     663                                /* translators: %s: Theme name */
     664                                'activateThemeLabel'         => is_network_admin() ? _x( 'Network Activate %s', 'theme' ) : _x( 'Activate %s', 'theme' ),
    654665                                'activateImporter'           => __( 'Activate importer' ),
    655                                 'unknownError'               => __( 'An unknown error occured' ),
     666                                'unknownError'               => __( 'An unknown error occurred' ),
    656667                                'pluginsFound'               => __( 'Number of plugins found: %d' ),
    657668                                'noPluginsFound'             => __( 'No plugins found. Try a different search.' ),
  • trunk/tests/qunit/fixtures/updates.js

    r38033 r38057  
    2323                'installFailedShort': 'Install Failed!',
    2424                'installFailed': 'Installation failed: %s',
    25                 'installingLabel': 'Installing %s...', // No ellipsis
    26                 'installedLabel': '%s installed!',
    27                 'installFailedLabel': '%s installation failed',
     25                'pluginInstallingLabel': 'Installing %s...', // No ellipsis
     26                'themeInstallingLabel': 'Installing %s...', // No ellipsis
     27                'pluginInstalledLabel': '%s installed!',
     28                'themeInstalledLabel': '%s installed!',
     29                'pluginInstallFailedLabel': '%s installation failed',
     30                'themeInstallFailedLabel': '%s installation failed',
    2831                'installingMsg': 'Installing... please wait.',
    2932                'installedMsg': 'Installation completed successfully.',
    … …  
    3841                'livePreview': 'Live Preview',
    3942                'activatePlugin': 'Activate',
    40                 'activateTheme': 'Activate',
     43                'activateTheme':       'Activate',
     44                'activatePluginLabel': 'Activate %s',
     45                'activateThemeLabel':  'Activate %s',
    4146                'activateImporter': 'Activate importer',
    42                 'unknownError': 'An unknown error occured',
     47                'unknownError': 'An unknown error occurred',
    4348                'pluginsFound': 'Number of plugins found: %d',
    4449                'noPluginsFound': 'No plugins found. Try a different search.'
Note: See TracChangeset for help on using the changeset viewer.