Skip to content

Commit aaf2422

Browse files
committed
I18n: Combine duplicate text strings into variables.
In cases where a string is used both for a visible label and a screen reader text label, the screen reader text should never be different from the visible label. To help ensure this doesn't happen, use only a single string. The associated screen reader text comments are no longer required. This is also true for a few cases where there are strings in contexts where variables can't be used. In these cases, the screen reader text comments are also removed. Props sabernhardt, swissspidy, audrasjb, joedolson. Fixes #63620. git-svn-id: https://develop.svn.wordpress.org/trunk@60805 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 4dce339 commit aaf2422

File tree

12 files changed

+120
-271
lines changed

12 files changed

+120
-271
lines changed

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

Lines changed: 17 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,8 @@ public function admin_page() {
377377
<input name="background-preset" type="hidden" value="custom">
378378

379379
<?php
380+
$background_position_title = __( 'Image Position' );
381+
380382
$background_position = sprintf(
381383
'%s %s',
382384
get_theme_mod( 'background_position_x', get_theme_support( 'custom-background', 'default-position-x' ) ),
@@ -429,13 +431,8 @@ public function admin_page() {
429431
);
430432
?>
431433
<tr>
432-
<th scope="row"><?php _e( 'Image Position' ); ?></th>
433-
<td><fieldset><legend class="screen-reader-text"><span>
434-
<?php
435-
/* translators: Hidden accessibility text. */
436-
_e( 'Image Position' );
437-
?>
438-
</span></legend>
434+
<th scope="row"><?php echo $background_position_title; ?></th>
435+
<td><fieldset><legend class="screen-reader-text"><span><?php echo $background_position_title; ?></span></legend>
439436
<div class="background-position-control">
440437
<?php foreach ( $background_position_options as $group ) : ?>
441438
<div class="button-group">
@@ -452,14 +449,10 @@ public function admin_page() {
452449
</fieldset></td>
453450
</tr>
454451

452+
<?php $image_size_title = __( 'Image Size' ); ?>
455453
<tr>
456-
<th scope="row"><label for="background-size"><?php _e( 'Image Size' ); ?></label></th>
457-
<td><fieldset><legend class="screen-reader-text"><span>
458-
<?php
459-
/* translators: Hidden accessibility text. */
460-
_e( 'Image Size' );
461-
?>
462-
</span></legend>
454+
<th scope="row"><label for="background-size"><?php echo $image_size_title; ?></label></th>
455+
<td><fieldset><legend class="screen-reader-text"><span><?php echo $image_size_title; ?></span></legend>
463456
<select id="background-size" name="background-size">
464457
<option value="auto"<?php selected( 'auto', get_theme_mod( 'background_size', get_theme_support( 'custom-background', 'default-size' ) ) ); ?>><?php _ex( 'Original', 'Original Size' ); ?></option>
465458
<option value="contain"<?php selected( 'contain', get_theme_mod( 'background_size', get_theme_support( 'custom-background', 'default-size' ) ) ); ?>><?php _e( 'Fit to Screen' ); ?></option>
@@ -468,40 +461,29 @@ public function admin_page() {
468461
</fieldset></td>
469462
</tr>
470463

464+
<?php $background_repeat_title = _x( 'Repeat', 'Background Repeat' ); ?>
471465
<tr>
472-
<th scope="row"><?php _ex( 'Repeat', 'Background Repeat' ); ?></th>
473-
<td><fieldset><legend class="screen-reader-text"><span>
474-
<?php
475-
/* translators: Hidden accessibility text. */
476-
_ex( 'Repeat', 'Background Repeat' );
477-
?>
478-
</span></legend>
466+
<th scope="row"><?php echo $background_repeat_title; ?></th>
467+
<td><fieldset><legend class="screen-reader-text"><span><?php echo $background_repeat_title; ?></span></legend>
479468
<input name="background-repeat" type="hidden" value="no-repeat">
480469
<label><input type="checkbox" name="background-repeat" value="repeat"<?php checked( 'repeat', get_theme_mod( 'background_repeat', get_theme_support( 'custom-background', 'default-repeat' ) ) ); ?>> <?php _e( 'Repeat Background Image' ); ?></label>
481470
</fieldset></td>
482471
</tr>
483472

473+
<?php $background_scroll_title = _x( 'Scroll', 'Background Scroll' ); ?>
484474
<tr>
485-
<th scope="row"><?php _ex( 'Scroll', 'Background Scroll' ); ?></th>
486-
<td><fieldset><legend class="screen-reader-text"><span>
487-
<?php
488-
/* translators: Hidden accessibility text. */
489-
_ex( 'Scroll', 'Background Scroll' );
490-
?>
491-
</span></legend>
475+
<th scope="row"><?php echo $background_scroll_title; ?></th>
476+
<td><fieldset><legend class="screen-reader-text"><span><?php echo $background_scroll_title; ?></span></legend>
492477
<input name="background-attachment" type="hidden" value="fixed">
493478
<label><input name="background-attachment" type="checkbox" value="scroll" <?php checked( 'scroll', get_theme_mod( 'background_attachment', get_theme_support( 'custom-background', 'default-attachment' ) ) ); ?>> <?php _e( 'Scroll with Page' ); ?></label>
494479
</fieldset></td>
495480
</tr>
496481
<?php endif; // get_background_image() ?>
482+
483+
<?php $background_color_title = __( 'Background Color' ); ?>
497484
<tr>
498-
<th scope="row"><?php _e( 'Background Color' ); ?></th>
499-
<td><fieldset><legend class="screen-reader-text"><span>
500-
<?php
501-
/* translators: Hidden accessibility text. */
502-
_e( 'Background Color' );
503-
?>
504-
</span></legend>
485+
<th scope="row"><?php echo $background_color_title; ?></th>
486+
<td><fieldset><legend class="screen-reader-text"><span><?php echo $background_color_title; ?></span></legend>
505487
<?php
506488
$default_color = '';
507489
if ( current_theme_supports( 'custom-background', 'default-color' ) ) {

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

Lines changed: 22 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,12 +1228,7 @@ function link_categories_meta_box( $link ) {
12281228
function link_target_meta_box( $link ) {
12291229

12301230
?>
1231-
<fieldset><legend class="screen-reader-text"><span>
1232-
<?php
1233-
/* translators: Hidden accessibility text. */
1234-
_e( 'Target' );
1235-
?>
1236-
</span></legend>
1231+
<fieldset><legend class="screen-reader-text"><span><?php _e( 'Target' ); ?></span></legend>
12371232
<p><label for="link_target_blank" class="selectit">
12381233
<input id="link_target_blank" type="radio" name="link_target" value="_blank" <?php echo ( isset( $link->link_target ) && ( '_blank' === $link->link_target ) ? 'checked="checked"' : '' ); ?> />
12391234
<?php _e( '<code>_blank</code> &mdash; new window or tab.' ); ?></label></p>
@@ -1321,29 +1316,21 @@ function link_xfn_meta_box( $link ) {
13211316
<th scope="row"><label for="link_rel"><?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'rel:' ); ?></label></th>
13221317
<td><input type="text" name="link_rel" id="link_rel" value="<?php echo ( isset( $link->link_rel ) ? esc_attr( $link->link_rel ) : '' ); ?>" /></td>
13231318
</tr>
1319+
<?php $identity_group_title = /* translators: xfn: https://gmpg.org/xfn/ */ __( 'identity' ); ?>
13241320
<tr>
1325-
<th scope="row"><?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'identity' ); ?></th>
1321+
<th scope="row"><?php echo $identity_group_title; ?></th>
13261322
<td><fieldset>
1327-
<legend class="screen-reader-text"><span>
1328-
<?php
1329-
/* translators: Hidden accessibility text. xfn: https://gmpg.org/xfn/ */
1330-
_e( 'identity' );
1331-
?>
1332-
</span></legend>
1323+
<legend class="screen-reader-text"><span><?php echo $identity_group_title; ?></span></legend>
13331324
<label for="me">
13341325
<input type="checkbox" name="identity" value="me" id="me" <?php xfn_check( 'identity', 'me' ); ?> />
13351326
<?php _e( 'another web address of mine' ); ?></label>
13361327
</fieldset></td>
13371328
</tr>
1329+
<?php $friendship_group_title = /* translators: xfn: https://gmpg.org/xfn/ */ __( 'friendship' ); ?>
13381330
<tr>
1339-
<th scope="row"><?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'friendship' ); ?></th>
1331+
<th scope="row"><?php echo $friendship_group_title; ?></th>
13401332
<td><fieldset>
1341-
<legend class="screen-reader-text"><span>
1342-
<?php
1343-
/* translators: Hidden accessibility text. xfn: https://gmpg.org/xfn/ */
1344-
_e( 'friendship' );
1345-
?>
1346-
</span></legend>
1333+
<legend class="screen-reader-text"><span><?php echo $friendship_group_title; ?></span></legend>
13471334
<label for="contact">
13481335
<input class="valinp" type="radio" name="friendship" value="contact" id="contact" <?php xfn_check( 'friendship', 'contact' ); ?> />&nbsp;<?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'contact' ); ?>
13491336
</label>
@@ -1358,29 +1345,21 @@ function link_xfn_meta_box( $link ) {
13581345
</label>
13591346
</fieldset></td>
13601347
</tr>
1348+
<?php $physical_group_title = /* translators: xfn: https://gmpg.org/xfn/ */ __( 'physical' ); ?>
13611349
<tr>
1362-
<th scope="row"> <?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'physical' ); ?> </th>
1350+
<th scope="row"> <?php echo $physical_group_title; ?> </th>
13631351
<td><fieldset>
1364-
<legend class="screen-reader-text"><span>
1365-
<?php
1366-
/* translators: Hidden accessibility text. xfn: https://gmpg.org/xfn/ */
1367-
_e( 'physical' );
1368-
?>
1369-
</span></legend>
1352+
<legend class="screen-reader-text"><span><?php echo $physical_group_title; ?></span></legend>
13701353
<label for="met">
13711354
<input class="valinp" type="checkbox" name="physical" value="met" id="met" <?php xfn_check( 'physical', 'met' ); ?> />&nbsp;<?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'met' ); ?>
13721355
</label>
13731356
</fieldset></td>
13741357
</tr>
1358+
<?php $professional_group_title = /* translators: xfn: https://gmpg.org/xfn/ */ __( 'professional' ); ?>
13751359
<tr>
1376-
<th scope="row"> <?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'professional' ); ?> </th>
1360+
<th scope="row"> <?php echo $professional_group_title; ?> </th>
13771361
<td><fieldset>
1378-
<legend class="screen-reader-text"><span>
1379-
<?php
1380-
/* translators: Hidden accessibility text. xfn: https://gmpg.org/xfn/ */
1381-
_e( 'professional' );
1382-
?>
1383-
</span></legend>
1362+
<legend class="screen-reader-text"><span><?php echo $professional_group_title; ?></span></legend>
13841363
<label for="co-worker">
13851364
<input class="valinp" type="checkbox" name="professional" value="co-worker" id="co-worker" <?php xfn_check( 'professional', 'co-worker' ); ?> />&nbsp;<?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'co-worker' ); ?>
13861365
</label>
@@ -1389,15 +1368,11 @@ function link_xfn_meta_box( $link ) {
13891368
</label>
13901369
</fieldset></td>
13911370
</tr>
1371+
<?php $geographical_group_title = /* translators: xfn: https://gmpg.org/xfn/ */ __( 'geographical' ); ?>
13921372
<tr>
1393-
<th scope="row"><?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'geographical' ); ?></th>
1373+
<th scope="row"><?php echo $geographical_group_title; ?></th>
13941374
<td><fieldset>
1395-
<legend class="screen-reader-text"><span>
1396-
<?php
1397-
/* translators: Hidden accessibility text. xfn: https://gmpg.org/xfn/ */
1398-
_e( 'geographical' );
1399-
?>
1400-
</span></legend>
1375+
<legend class="screen-reader-text"><span><?php echo $geographical_group_title; ?></span></legend>
14011376
<label for="co-resident">
14021377
<input class="valinp" type="radio" name="geographical" value="co-resident" id="co-resident" <?php xfn_check( 'geographical', 'co-resident' ); ?> />&nbsp;<?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'co-resident' ); ?>
14031378
</label>
@@ -1409,15 +1384,11 @@ function link_xfn_meta_box( $link ) {
14091384
</label>
14101385
</fieldset></td>
14111386
</tr>
1387+
<?php $family_group_title = /* translators: xfn: https://gmpg.org/xfn/ */ __( 'family' ); ?>
14121388
<tr>
1413-
<th scope="row"><?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'family' ); ?></th>
1389+
<th scope="row"><?php echo $family_group_title; ?></th>
14141390
<td><fieldset>
1415-
<legend class="screen-reader-text"><span>
1416-
<?php
1417-
/* translators: Hidden accessibility text. xfn: https://gmpg.org/xfn/ */
1418-
_e( 'family' );
1419-
?>
1420-
</span></legend>
1391+
<legend class="screen-reader-text"><span><?php echo $family_group_title; ?></span></legend>
14211392
<label for="child">
14221393
<input class="valinp" type="radio" name="family" value="child" id="child" <?php xfn_check( 'family', 'child' ); ?> />&nbsp;<?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'child' ); ?>
14231394
</label>
@@ -1438,15 +1409,11 @@ function link_xfn_meta_box( $link ) {
14381409
</label>
14391410
</fieldset></td>
14401411
</tr>
1412+
<?php $romantic_group_title = /* translators: xfn: https://gmpg.org/xfn/ */ __( 'romantic' ); ?>
14411413
<tr>
1442-
<th scope="row"><?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'romantic' ); ?></th>
1414+
<th scope="row"><?php echo $romantic_group_title; ?></th>
14431415
<td><fieldset>
1444-
<legend class="screen-reader-text"><span>
1445-
<?php
1446-
/* translators: Hidden accessibility text. xfn: https://gmpg.org/xfn/ */
1447-
_e( 'romantic' );
1448-
?>
1449-
</span></legend>
1416+
<legend class="screen-reader-text"><span><?php echo $romantic_group_title; ?></span></legend>
14501417
<label for="muse">
14511418
<input class="valinp" type="checkbox" name="romantic" value="muse" id="muse" <?php xfn_check( 'romantic', 'muse' ); ?> />&nbsp;<?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'muse' ); ?>
14521419
</label>

src/wp-admin/includes/misc.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,12 +1022,7 @@ function admin_color_scheme_picker( $user_id ) {
10221022
}
10231023
?>
10241024
<fieldset id="color-picker" class="scheme-list">
1025-
<legend class="screen-reader-text"><span>
1026-
<?php
1027-
/* translators: Hidden accessibility text. */
1028-
_e( 'Administration Color Scheme' );
1029-
?>
1030-
</span></legend>
1025+
<legend class="screen-reader-text"><span><?php _e( 'Administration Color Scheme' ); ?></span></legend>
10311026
<?php
10321027
wp_nonce_field( 'save-color-scheme', 'color-nonce', false );
10331028
foreach ( $_wp_admin_css_colors as $color => $color_info ) :

src/wp-admin/install.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -180,19 +180,12 @@ function display_setup_form( $error = null ) {
180180
<td><input name="admin_email" type="email" id="admin_email" size="25" aria-describedby="admin-email-desc" value="<?php echo esc_attr( $admin_email ); ?>" />
181181
<p id="admin-email-desc"><?php _e( 'Double-check your email address before continuing.' ); ?></p></td>
182182
</tr>
183+
<?php $blog_privacy_selector_title = has_action( 'blog_privacy_selector' ) ? __( 'Site visibility' ) : __( 'Search engine visibility' ); ?>
183184
<tr>
184-
<th scope="row"><?php has_action( 'blog_privacy_selector' ) ? _e( 'Site visibility' ) : _e( 'Search engine visibility' ); ?></th>
185+
<th scope="row"><?php echo $blog_privacy_selector_title; ?></th>
185186
<td>
186187
<fieldset>
187-
<legend class="screen-reader-text"><span>
188-
<?php
189-
has_action( 'blog_privacy_selector' )
190-
/* translators: Hidden accessibility text. */
191-
? _e( 'Site visibility' )
192-
/* translators: Hidden accessibility text. */
193-
: _e( 'Search engine visibility' );
194-
?>
195-
</span></legend>
188+
<legend class="screen-reader-text"><span><?php echo $blog_privacy_selector_title; ?></span></legend>
196189
<?php
197190
if ( has_action( 'blog_privacy_selector' ) ) {
198191
?>

src/wp-admin/network/settings.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,9 @@
199199
</table>
200200
<h2><?php _e( 'Registration Settings' ); ?></h2>
201201
<table class="form-table" role="presentation">
202+
<?php $new_registrations_settings_title = __( 'Allow new registrations' ); ?>
202203
<tr>
203-
<th scope="row"><?php _e( 'Allow new registrations' ); ?></th>
204+
<th scope="row"><?php echo $new_registrations_settings_title; ?></th>
204205
<?php
205206
if ( ! get_site_option( 'registration' ) ) {
206207
update_site_option( 'registration', 'none' );
@@ -209,12 +210,7 @@
209210
?>
210211
<td>
211212
<fieldset>
212-
<legend class="screen-reader-text">
213-
<?php
214-
/* translators: Hidden accessibility text. */
215-
_e( 'New registrations settings' );
216-
?>
217-
</legend>
213+
<legend class="screen-reader-text"><?php echo $new_registrations_settings_title; ?></legend>
218214
<label><input name="registration" type="radio" id="registration1" value="none"<?php checked( $reg, 'none' ); ?> /> <?php _e( 'Registration is disabled' ); ?></label><br />
219215
<label><input name="registration" type="radio" id="registration2" value="user"<?php checked( $reg, 'user' ); ?> /> <?php _e( 'User accounts may be registered' ); ?></label><br />
220216
<label><input name="registration" type="radio" id="registration3" value="blog"<?php checked( $reg, 'blog' ); ?> /> <?php _e( 'Logged in users may register new sites' ); ?></label><br />
@@ -510,14 +506,12 @@
510506
?>
511507
<h2><?php _e( 'Menu Settings' ); ?></h2>
512508
<table id="menu" class="form-table">
509+
<?php $enable_administration_menus_title = __( 'Enable administration menus' ); ?>
513510
<tr>
514-
<th scope="row"><?php _e( 'Enable administration menus' ); ?></th>
511+
<th scope="row"><?php echo $enable_administration_menus_title; ?></th>
515512
<td>
516513
<?php
517-
echo '<fieldset><legend class="screen-reader-text">' .
518-
/* translators: Hidden accessibility text. */
519-
__( 'Enable menus' ) .
520-
'</legend>';
514+
echo '<fieldset><legend class="screen-reader-text">' . $enable_administration_menus_title . '</legend>';
521515

522516
foreach ( (array) $menu_items as $key => $val ) {
523517
echo "<label><input type='checkbox' name='menu_items[" . $key . "]' value='1'" . ( isset( $menu_perms[ $key ] ) ? checked( $menu_perms[ $key ], '1', false ) : '' ) . ' /> ' . esc_html( $val ) . '</label><br/>';

src/wp-admin/network/site-info.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@
196196
<td><input name="blog[last_updated]" type="text" id="blog_last_updated" value="<?php echo esc_attr( $details->last_updated ); ?>" /></td>
197197
</tr>
198198
<?php
199+
$site_attributes_title = __( 'Attributes' );
200+
199201
$attribute_fields = array( 'public' => _x( 'Public', 'site' ) );
200202
if ( ! $is_main_site ) {
201203
$attribute_fields['archived'] = __( 'Archived' );
@@ -205,15 +207,10 @@
205207
$attribute_fields['mature'] = __( 'Mature' );
206208
?>
207209
<tr>
208-
<th scope="row"><?php _e( 'Attributes' ); ?></th>
210+
<th scope="row"><?php echo $site_attributes_title; ?></th>
209211
<td>
210212
<fieldset>
211-
<legend class="screen-reader-text">
212-
<?php
213-
/* translators: Hidden accessibility text. */
214-
_e( 'Set site attributes' );
215-
?>
216-
</legend>
213+
<legend class="screen-reader-text"><?php echo $site_attributes_title; ?></legend>
217214
<?php foreach ( $attribute_fields as $field_key => $field_label ) : ?>
218215
<label><input type="checkbox" name="blog[<?php echo $field_key; ?>]" value="1" <?php checked( (bool) $details->$field_key, true ); ?> <?php disabled( ! in_array( (int) $details->$field_key, array( 0, 1 ), true ) ); ?> />
219216
<?php echo $field_label; ?></label><br />

0 commit comments

Comments
 (0)