Skip to content

Commit 0f3b526

Browse files
committed
I18N: Add translator context to all 'Preview' strings.
`Preview` is a single English token that lands in translations as a verb (button labels), a noun (preview panes, table headers), or an iframe title. Without a translator context, all 14 in-tree occurrences collapsed onto one entry in `default.po`, forcing translators to choose a single rendering that fit poorly somewhere. This commit gives each occurrence a context that names both the part of speech and the surface it appears on, covering: * Post row action and post-lock dialog button (`verb, ...`). * Submit meta box preview button (`verb, action button to preview the post`). * Theme install list-table action and theme-install template buttons (`verb, ...`). * Theme preview iframe title (`noun, ...`). * Customizer toggle and takeover dialog (`verb`/`noun`, ...). * Header image and background image preview rows (`noun, ...`). * Classic-editor (TinyMCE) toolbar button (`verb, ...`). Extends the scope of GH-11407 and GH-11408, which only covered four of these spots. See #64986.
1 parent baa9f53 commit 0f3b526

10 files changed

Lines changed: 14 additions & 14 deletions

src/wp-admin/customize.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@
210210
<span class="spinner"></span>
211211
<button type="button" class="customize-controls-preview-toggle">
212212
<span class="controls"><?php _e( 'Customize' ); ?></span>
213-
<span class="preview"><?php _e( 'Preview' ); ?></span>
213+
<span class="preview"><?php echo esc_html_x( 'Preview', 'noun, customizer toggle label for the preview pane' ); ?></span>
214214
</button>
215215
<a class="customize-controls-close" href="<?php echo esc_url( $wp_customize->get_return_url() ); ?>">
216216
<span class="screen-reader-text">

src/wp-admin/includes/class-custom-background.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ public function admin_page() {
279279
<table class="form-table" role="presentation">
280280
<tbody>
281281
<tr>
282-
<th scope="row"><?php _e( 'Preview' ); ?></th>
282+
<th scope="row"><?php echo esc_html_x( 'Preview', 'noun, table row label for the background image preview' ); ?></th>
283283
<td>
284284
<?php
285285
if ( $this->admin_image_div_callback ) {

src/wp-admin/includes/class-custom-image-header.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ public function step_1() {
550550

551551
<?php if ( get_custom_header() || display_header_text() ) : ?>
552552
<tr>
553-
<th scope="row"><?php _e( 'Preview' ); ?></th>
553+
<th scope="row"><?php echo esc_html_x( 'Preview', 'noun, table row label for the header image preview' ); ?></th>
554554
<td>
555555
<?php
556556
if ( $this->admin_image_div_callback ) {

src/wp-admin/includes/class-wp-posts-list-table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1589,7 +1589,7 @@ protected function handle_row_actions( $item, $column_name, $primary ) {
15891589
esc_url( $preview_link ),
15901590
/* translators: %s: Post title. */
15911591
esc_attr( sprintf( __( 'Preview &#8220;%s&#8221;' ), $title ) ),
1592-
__( 'Preview' )
1592+
_x( 'Preview', 'verb, post row action to preview a post' )
15931593
);
15941594
}
15951595
} elseif ( 'trash' !== $post->post_status ) {

src/wp-admin/includes/class-wp-theme-install-list-table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ public function single_row( $theme ) {
345345
'<a class="install-theme-preview" href="%s" aria-label="%s">%s</a>',
346346
esc_url( $preview_url ),
347347
esc_attr( $preview_title ),
348-
__( 'Preview' )
348+
_x( 'Preview', 'verb, theme row action to preview a theme' )
349349
);
350350

351351
/**

src/wp-admin/includes/meta-boxes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function post_submit_meta_box( $post, $args = array() ) {
7070
if ( 'publish' === $post->post_status ) {
7171
$preview_button_text = __( 'Preview Changes' );
7272
} else {
73-
$preview_button_text = __( 'Preview' );
73+
$preview_button_text = _x( 'Preview', 'verb, action button to preview the post' );
7474
}
7575

7676
$preview_button = sprintf(

src/wp-admin/includes/post.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1900,7 +1900,7 @@ function _admin_notice_post_locked() {
19001900
<p>
19011901
<a class="button" href="<?php echo esc_url( $sendback ); ?>"><?php echo $sendback_text; ?></a>
19021902
<?php if ( $preview_link ) { ?>
1903-
<a class="button<?php echo $tab_last; ?>" href="<?php echo esc_url( $preview_link ); ?>"><?php _e( 'Preview' ); ?></a>
1903+
<a class="button<?php echo $tab_last; ?>" href="<?php echo esc_url( $preview_link ); ?>"><?php echo esc_html_x( 'Preview', 'verb, button shown on the post-lock dialog' ); ?></a>
19041904
<?php
19051905
}
19061906

src/wp-admin/theme-install.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@
422422
<a class="button load-customize" href="{{ data.customize_url }}"><?php _e( 'Customize' ); ?></a>
423423
<# } #>
424424
<# } else { #>
425-
<button class="button preview install-theme-preview"><?php _e( 'Preview' ); ?></button>
425+
<button class="button preview install-theme-preview"><?php echo esc_html_x( 'Preview', 'verb, theme install action button' ); ?></button>
426426
<# } #>
427427
<# } else { #>
428428
<?php
@@ -435,7 +435,7 @@
435435
<# if ( data.customize_url ) { #>
436436
<a class="button disabled"><?php _e( 'Live Preview' ); ?></a>
437437
<# } else { #>
438-
<button class="button disabled"><?php _e( 'Preview' ); ?></button>
438+
<button class="button disabled"><?php echo esc_html_x( 'Preview', 'verb, theme install action button' ); ?></button>
439439
<# } #>
440440
<# } #>
441441
<# } else { #>
@@ -445,14 +445,14 @@
445445
$aria_label = sprintf( _x( 'Install %s', 'theme' ), '{{ data.name }}' );
446446
?>
447447
<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>
448-
<button class="button preview install-theme-preview"><?php _e( 'Preview' ); ?></button>
448+
<button class="button preview install-theme-preview"><?php echo esc_html_x( 'Preview', 'verb, theme install action button' ); ?></button>
449449
<# } else { #>
450450
<?php
451451
/* translators: %s: Theme name. */
452452
$aria_label = sprintf( _x( 'Cannot Install %s', 'theme' ), '{{ data.name }}' );
453453
?>
454454
<a class="button button-primary disabled" data-name="{{ data.name }}" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _ex( 'Cannot Install', 'theme' ); ?></a>
455-
<button class="button disabled"><?php _e( 'Preview' ); ?></button>
455+
<button class="button disabled"><?php echo esc_html_x( 'Preview', 'verb, theme install action button' ); ?></button>
456456
<# } #>
457457
<# } #>
458458
</div>
@@ -605,7 +605,7 @@
605605
</div>
606606
</div>
607607
<div class="wp-full-overlay-main">
608-
<iframe src="{{ data.preview_url }}" title="<?php esc_attr_e( 'Preview' ); ?>"></iframe>
608+
<iframe src="{{ data.preview_url }}" title="<?php echo esc_attr_x( 'Preview', 'noun, iframe title for the theme preview pane' ); ?>"></iframe>
609609
</div>
610610
</script>
611611

src/wp-includes/class-wp-customize-manager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4333,7 +4333,7 @@ public function render_control_templates() {
43334333
<# if ( data.returnUrl !== data.previewUrl ) { #>
43344334
<a class="button customize-notice-go-back-button" href="{{ data.returnUrl }}"><?php _e( 'Go back' ); ?></a>
43354335
<# } #>
4336-
<a class="button customize-notice-preview-button" href="{{ data.frontendPreviewUrl }}"><?php _e( 'Preview' ); ?></a>
4336+
<a class="button customize-notice-preview-button" href="{{ data.frontendPreviewUrl }}"><?php echo esc_html_x( 'Preview', 'verb, customizer takeover dialog action button' ); ?></a>
43374337
<# if ( data.allowOverride ) { #>
43384338
<button class="button button-primary wp-tab-last customize-notice-take-over-button"><?php _e( 'Take over' ); ?></button>
43394339
<# } #>

src/wp-includes/class-wp-editor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1252,7 +1252,7 @@ private static function get_translation() {
12521252
'Nonbreaking space' => __( 'Nonbreaking space' ),
12531253
'Page break' => __( 'Page break' ),
12541254
'Paste as text' => __( 'Paste as text' ),
1255-
'Preview' => __( 'Preview' ),
1255+
'Preview' => _x( 'Preview', 'verb, classic editor toolbar button label' ),
12561256
'Print' => __( 'Print' ),
12571257
'Save' => __( 'Save' ),
12581258
'Fullscreen' => __( 'Fullscreen' ),

0 commit comments

Comments
 (0)