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

Props swissspidy, SergeyBiryukov.
Fixes #37290.
Built from https://develop.svn.wordpress.org/trunk@38057


git-svn-id: http://core.svn.wordpress.org/trunk@37998 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dominik Schilling 2016-07-13 17:32:29 +00:00
parent 4418b71645
commit 98d03cb738
9 changed files with 87 additions and 32 deletions

View File

@ -3344,6 +3344,8 @@ function wp_ajax_install_theme() {
wp_send_json_error( $status );
}
$status['themeName'] = wp_get_theme( $slug )->get( 'Name' );
if ( current_user_can( 'switch_themes' ) ) {
if ( is_multisite() ) {
$status['activateUrl'] = add_query_arg( array(

View File

@ -635,7 +635,11 @@ function customize_themes_print_templates() {
<# if ( ! data.active ) { #>
<div class="theme-actions">
<div class="inactive-theme">
<a href="<?php echo $preview_url; ?>" target="_top" class="button button-primary"><?php _e( 'Live Preview' ); ?></a>
<?php
/* translators: %s: Theme name */
$aria_label = sprintf( __( 'Preview %s' ), '{{ data.name }}' );
?>
<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>
</div>
</div>
<# } #>

View File

@ -690,7 +690,7 @@ function wp_print_admin_notice_templates() {
* @type string colspan The number of table columns this row spans.
* @type string content The row content.
* }
*
*
* The delete template takes one argument with four values:
*
* param {object} data {
@ -716,13 +716,23 @@ function wp_print_update_row_templates() {
<script id="tmpl-item-deleted-row" type="text/template">
<tr class="plugin-deleted-tr inactive deleted" id="{{ data.slug }}-deleted" data-slug="{{ data.slug }}" <# if ( data.plugin ) { #>data-plugin="{{ data.plugin }}"<# } #>>
<td colspan="{{ data.colspan }}" class="plugin-update colspanchange">
<?php
printf(
/* translators: %s: Plugin or Theme name */
__( '%s was successfully deleted.' ),
'<strong>{{{ data.name }}}</strong>'
);
?>
<# if ( data.plugin ) { #>
<?php
printf(
/* translators: %s: Plugin name */
_x( '%s was successfully deleted.', 'plugin' ),
'<strong>{{{ data.name }}}</strong>'
);
?>
<# } else { #>
<?php
printf(
/* translators: %s: Theme name */
_x( '%s was successfully deleted.', 'theme' ),
'<strong>{{{ data.name }}}</strong>'
);
?>
<# } #>
</td>
</tr>
</script>

View File

@ -508,7 +508,9 @@
$message.text( wp.updates.l10n.installing );
}
$message.addClass( 'updating-message' );
$message
.addClass( 'updating-message' )
.attr( 'aria-label', wp.updates.l10n.pluginInstallingLabel.replace( '%s', $message.data( 'name' ) ) );
wp.a11y.speak( wp.updates.l10n.installingMsg, 'polite' );
@ -535,6 +537,7 @@
$message
.removeClass( 'updating-message' )
.addClass( 'updated-message installed button-disabled' )
.attr( 'aria-label', wp.updates.l10n.pluginInstalledLabel.replace( '%s', response.pluginName ) )
.text( wp.updates.l10n.installed );
wp.a11y.speak( wp.updates.l10n.installedMsg, 'polite' );
@ -547,6 +550,7 @@
// Transform the 'Install' button into an 'Activate' button.
$message.removeClass( 'install-now installed button-disabled updated-message' ).addClass( 'activate-now button-primary' )
.attr( 'href', response.activateUrl )
.attr( 'aria-label', wp.updates.l10n.activatePluginLabel.replace( '%s', response.pluginName ) )
.text( wp.updates.l10n.activatePlugin );
}, 1000 );
}
@ -595,7 +599,7 @@
$button
.removeClass( 'updating-message' ).addClass( 'button-disabled' )
.attr( 'aria-label', wp.updates.l10n.installFailedLabel.replace( '%s', response.pluginName ) )
.attr( 'aria-label', wp.updates.l10n.pluginInstallFailedLabel.replace( '%s', $button.data( 'name' ) ) )
.text( wp.updates.l10n.installFailedShort );
wp.a11y.speak( errorMessage, 'assertive' );
@ -1003,7 +1007,9 @@
$message.data( 'originaltext', $message.html() );
}
$message.text( wp.updates.l10n.installing );
$message
.text( wp.updates.l10n.installing )
.attr( 'aria-label', wp.updates.l10n.themeInstallingLabel.replace( '%s', $message.data( 'name' ) ) );
wp.a11y.speak( wp.updates.l10n.installingMsg, 'polite' );
// Remove previous error messages, if any.
@ -1032,6 +1038,7 @@
$message = $card.find( '.button-primary' )
.removeClass( 'updating-message' )
.addClass( 'updated-message disabled' )
.attr( 'aria-label', wp.updates.l10n.themeInstalledLabel.replace( '%s', response.themeName ) )
.text( wp.updates.l10n.installed );
wp.a11y.speak( wp.updates.l10n.installedMsg, 'polite' );
@ -1045,6 +1052,7 @@
.attr( 'href', response.activateUrl )
.removeClass( 'theme-install updated-message disabled' )
.addClass( 'activate' )
.attr( 'aria-label', wp.updates.l10n.activateThemeLabel.replace( '%s', response.themeName ) )
.text( wp.updates.l10n.activateTheme );
}
@ -1098,7 +1106,7 @@
$button
.removeClass( 'updating-message' )
.attr( 'aria-label', wp.updates.l10n.installFailedLabel.replace( '%s', $card.find( '.theme-name' ).text() ) )
.attr( 'aria-label', wp.updates.l10n.themeInstallFailedLabel.replace( '%s', $button.data( 'name' ) ) )
.text( wp.updates.l10n.installFailedShort );
wp.a11y.speak( errorMessage, 'assertive' );

File diff suppressed because one or more lines are too long

View File

@ -248,17 +248,25 @@ if ( $tab ) {
<div class="theme-actions">
<# if ( data.installed ) { #>
<?php
/* translators: %s: Theme name */
$aria_label = sprintf( __( 'Activate %s' ), '{{ data.name }}' );
?>
<# if ( data.activate_url ) { #>
<a class="button button-primary activate" href="{{ data.activate_url }}"><?php esc_html_e( 'Activate' ); ?></a>
<a class="button button-primary activate" href="{{ data.activate_url }}" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a>
<# } #>
<# if ( data.customize_url ) { #>
<a class="button button-secondary load-customize" href="{{ data.customize_url }}"><?php esc_html_e( 'Live Preview' ); ?></a>
<a class="button button-secondary load-customize" href="{{ data.customize_url }}"><?php _e( 'Live Preview' ); ?></a>
<# } else { #>
<button class="button-secondary preview install-theme-preview"><?php esc_html_e( 'Preview' ); ?></button>
<button class="button-secondary preview install-theme-preview"><?php _e( 'Preview' ); ?></button>
<# } #>
<# } else { #>
<a class="button button-primary theme-install" data-slug="{{ data.id }}" href="{{ data.install_url }}"><?php esc_html_e( 'Install' ); ?></a>
<button class="button-secondary preview install-theme-preview"><?php esc_html_e( 'Preview' ); ?></button>
<?php
/* translators: %s: Theme name */
$aria_label = sprintf( __( 'Install %s' ), '{{ data.name }}' );
?>
<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>
<button class="button-secondary preview install-theme-preview"><?php _e( 'Preview' ); ?></button>
<# } #>
</div>
@ -274,9 +282,9 @@ if ( $tab ) {
<button class="previous-theme"><span class="screen-reader-text"><?php _ex( 'Previous', 'Button label for a theme' ); ?></span></button>
<button class="next-theme"><span class="screen-reader-text"><?php _ex( 'Next', 'Button label for a theme' ); ?></span></button>
<# if ( data.installed ) { #>
<a class="button button-primary activate" href="{{ data.activate_url }}"><?php esc_html_e( 'Activate' ); ?></a>
<a class="button button-primary activate" href="{{ data.activate_url }}"><?php _e( 'Activate' ); ?></a>
<# } else { #>
<a href="{{ data.install_url }}" class="button button-primary theme-install" data-slug="{{ data.id }}"><?php _e( 'Install' ); ?></a>
<a href="{{ data.install_url }}" class="button button-primary theme-install" data-name="{{ data.name }}" data-slug="{{ data.id }}"><?php _e( 'Install' ); ?></a>
<# } #>
</div>
<div class="wp-full-overlay-sidebar-content">

View File

@ -277,7 +277,11 @@ foreach ( $themes as $theme ) :
<a class="button button-primary customize load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Customize' ); ?></a>
<?php } ?>
<?php } else { ?>
<a class="button button-secondary activate" href="<?php echo $theme['actions']['activate']; ?>"><?php _e( 'Activate' ); ?></a>
<?php
/* translators: %s: Theme name */
$aria_label = sprintf( __( 'Activate %s' ), '{{ data.name }}' );
?>
<a class="button button-secondary activate" href="<?php echo $theme['actions']['activate']; ?>" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a>
<?php if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?>
<a class="button button-primary load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Live Preview' ); ?></a>
<?php } ?>
@ -402,7 +406,11 @@ $can_install = current_user_can( 'install_themes' );
<a class="button button-primary customize load-customize hide-if-no-customize" href="{{{ data.actions.customize }}}"><?php _e( 'Customize' ); ?></a>
<# } #>
<# } else { #>
<a class="button button-secondary activate" href="{{{ data.actions.activate }}}"><?php _e( 'Activate' ); ?></a>
<?php
/* translators: %s: Theme name */
$aria_label = sprintf( __( 'Activate %s' ), '{{ data.name }}' );
?>
<a class="button button-secondary activate" href="{{{ data.actions.activate }}}" aria-label="<?php echo $aria_label; ?>"><?php _e( 'Activate' ); ?></a>
<a class="button button-primary load-customize hide-if-no-customize" href="{{{ data.actions.customize }}}"><?php _e( 'Live Preview' ); ?></a>
<# } #>
</div>
@ -456,8 +464,12 @@ $can_install = current_user_can( 'install_themes' );
<?php echo implode( ' ', $current_theme_actions ); ?>
</div>
<div class="inactive-theme">
<?php
/* translators: %s: Theme name */
$aria_label = sprintf( __( 'Activate %s' ), '{{ data.name }}' );
?>
<# if ( data.actions.activate ) { #>
<a href="{{{ data.actions.activate }}}" class="button button-secondary activate"><?php _e( 'Activate' ); ?></a>
<a href="{{{ data.actions.activate }}}" class="button button-secondary activate" aria-label="<?php echo $aria_label; ?>"><?php _e( 'Activate' ); ?></a>
<# } #>
<a href="{{{ data.actions.customize }}}" class="button button-primary load-customize hide-if-no-customize"><?php _e( 'Live Preview' ); ?></a>
</div>

View File

@ -628,12 +628,18 @@ function wp_default_scripts( &$scripts ) {
'installFailedShort' => __( 'Install Failed!' ),
/* translators: Error string for a failed installation */
'installFailed' => __( 'Installation failed: %s' ),
/* translators: Plugin/Theme name and version */
'installingLabel' => __( 'Installing %s...' ), // no ellipsis
/* translators: Plugin/Theme name and version */
'installedLabel' => __( '%s installed!' ),
/* translators: Plugin/Theme name and version */
'installFailedLabel' => __( '%s installation failed' ),
/* translators: Plugin name and version */
'pluginInstallingLabel' => _x( 'Installing %s...', 'plugin' ), // no ellipsis
/* translators: Theme name and version */
'themeInstallingLabel' => _x( 'Installing %s...', 'theme' ), // no ellipsis
/* translators: Plugin name and version */
'pluginInstalledLabel' => _x( '%s installed!', 'plugin' ),
/* translators: Theme name and version */
'themeInstalledLabel' => _x( '%s installed!', 'theme' ),
/* translators: Plugin name and version */
'pluginInstallFailedLabel' => _x( '%s installation failed', 'plugin' ),
/* translators: Theme name and version */
'themeInstallFailedLabel' => _x( '%s installation failed', 'theme' ),
'installingMsg' => __( 'Installing... please wait.' ),
'installedMsg' => __( 'Installation completed successfully.' ),
/* translators: Activation URL */
@ -649,10 +655,15 @@ function wp_default_scripts( &$scripts ) {
'deleteFailed' => __( 'Deletion failed: %s' ),
'deleted' => __( 'Deleted!' ),
'livePreview' => __( 'Live Preview' ),
/* translators: %s: Theme name */
'activatePlugin' => is_network_admin() ? __( 'Network Activate' ) : __( 'Activate' ),
'activateTheme' => is_network_admin() ? __( 'Network Enable' ) : __( 'Activate' ),
/* translators: %s: Plugin name */
'activatePluginLabel' => is_network_admin() ? _x( 'Network Activate %s', 'plugin' ) : _x( 'Activate %s', 'plugin' ),
/* translators: %s: Theme name */
'activateThemeLabel' => is_network_admin() ? _x( 'Network Activate %s', 'theme' ) : _x( 'Activate %s', 'theme' ),
'activateImporter' => __( 'Activate importer' ),
'unknownError' => __( 'An unknown error occured' ),
'unknownError' => __( 'An unknown error occurred' ),
'pluginsFound' => __( 'Number of plugins found: %d' ),
'noPluginsFound' => __( 'No plugins found. Try a different search.' ),
),

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.6-beta2-38056';
$wp_version = '4.6-beta2-38057';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.