Skip to content

Commit a37a720

Browse files
committed
i18n: Define List item separator as a WP_Locale property.
The list item separator is a locale property, and it doesn't make much sense to translate it separately in multiple projects. This changeset implements the following modifications: - Define list item separator as a new WP_Locale property - Add `wp_get_list_item_separator()` as a wrapper for `WP_Locale::get_list_item_separator` - Replace `$wp_locale->get_list_item_separator()` calls with `wp_get_list_item_separator()` - Added a compatibility layer for bundled themes Props SergeyBiryukov, swissspidy, rsiddharth, johnbillion, audrasjb. Fixes #39733. git-svn-id: https://develop.svn.wordpress.org/trunk@52929 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 89de8f3 commit a37a720

20 files changed

Lines changed: 146 additions & 52 deletions

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,8 +633,7 @@ public function column_default( $item, $column_name ) {
633633
esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) )
634634
);
635635
}
636-
/* translators: Used between list items, there is a space after the comma. */
637-
echo implode( __( ', ' ), $out );
636+
echo implode( wp_get_list_item_separator(), $out );
638637
} else {
639638
echo '<span aria-hidden="true">&#8212;</span><span class="screen-reader-text">' . get_taxonomy( $taxonomy )->labels->no_terms . '</span>';
640639
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,8 +1294,7 @@ public function column_default( $item, $column_name ) {
12941294
*/
12951295
$term_links = apply_filters( 'post_column_taxonomy_links', $term_links, $taxonomy, $terms );
12961296

1297-
/* translators: Used between list items, there is a space after the comma. */
1298-
echo implode( __( ', ' ), $term_links );
1297+
echo implode( wp_get_list_item_separator(), $term_links );
12991298
} else {
13001299
echo '<span aria-hidden="true">&#8212;</span><span class="screen-reader-text">' . $taxonomy_object->labels->no_terms . '</span>';
13011300
}

src/wp-content/themes/twentyeleven/content-featured.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@
3232

3333
<footer class="entry-meta">
3434
<?php
35-
/* translators: Used between list items, there is a space after the comma. */
36-
$tags_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) );
35+
$tags_list = get_the_tag_list( '', wp_get_list_item_separator() );
3736

3837
if ( $tags_list && ! is_wp_error( $tags_list ) ) {
3938
/* translators: 1: Category list, 2: Tag list, 3: Post permalink, 4: Post title. */
@@ -45,8 +44,7 @@
4544

4645
printf(
4746
$utility_text,
48-
/* translators: Used between list items, there is a space after the comma. */
49-
get_the_category_list( __( ', ', 'twentyeleven' ) ),
47+
get_the_category_list( wp_get_list_item_separator() ),
5048
$tags_list,
5149
esc_url( get_permalink() ),
5250
the_title_attribute( 'echo=0' )

src/wp-content/themes/twentyeleven/content-gallery.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@
7272
<?php $show_sep = false; ?>
7373

7474
<?php
75-
/* translators: Used between list items, there is a space after the comma. */
76-
$categories_list = get_the_category_list( __( ', ', 'twentyeleven' ) );
75+
$categories_list = get_the_category_list( wp_get_list_item_separator() );
7776

7877
if ( $categories_list ) :
7978
?>
@@ -87,8 +86,7 @@
8786
<?php endif; // End if categories. ?>
8887

8988
<?php
90-
/* translators: Used between list items, there is a space after the comma. */
91-
$tags_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) );
89+
$tags_list = get_the_tag_list( '', wp_get_list_item_separator() );
9290

9391
if ( $tags_list && ! is_wp_error( $tags_list ) ) :
9492
if ( $show_sep ) :

src/wp-content/themes/twentyeleven/content-image.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@
5555
</div><!-- .entry-meta -->
5656
<div class="entry-meta">
5757
<?php
58-
/* translators: Used between list items, there is a space after the comma. */
59-
$categories_list = get_the_category_list( __( ', ', 'twentyeleven' ) );
58+
$categories_list = get_the_category_list( wp_get_list_item_separator() );
6059

6160
if ( $categories_list ) :
6261
?>
@@ -69,8 +68,7 @@
6968
<?php endif; // End if categories. ?>
7069

7170
<?php
72-
/* translators: Used between list items, there is a space after the comma. */
73-
$tags_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) );
71+
$tags_list = get_the_tag_list( '', wp_get_list_item_separator() );
7472

7573
if ( $tags_list && ! is_wp_error( $tags_list ) ) :
7674
?>

src/wp-content/themes/twentyeleven/content-quote.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@
4848
<?php $show_sep = false; ?>
4949

5050
<?php
51-
/* translators: Used between list items, there is a space after the comma. */
52-
$categories_list = get_the_category_list( __( ', ', 'twentyeleven' ) );
51+
$categories_list = get_the_category_list( wp_get_list_item_separator() );
5352

5453
if ( $categories_list ) :
5554
?>
@@ -63,8 +62,7 @@
6362
<?php endif; // End if categories. ?>
6463

6564
<?php
66-
/* translators: Used between list items, there is a space after the comma. */
67-
$tags_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) );
65+
$tags_list = get_the_tag_list( '', wp_get_list_item_separator() );
6866

6967
if ( $tags_list && ! is_wp_error( $tags_list ) ) :
7068
if ( $show_sep ) :

src/wp-content/themes/twentyeleven/content-single.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,9 @@
3333

3434
<footer class="entry-meta">
3535
<?php
36-
/* translators: Used between list items, there is a space after the comma. */
37-
$categories_list = get_the_category_list( __( ', ', 'twentyeleven' ) );
36+
$categories_list = get_the_category_list( wp_get_list_item_separator() );
3837

39-
/* translators: Used between list items, there is a space after the comma. */
40-
$tags_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) );
38+
$tags_list = get_the_tag_list( '', wp_get_list_item_separator() );
4139

4240
if ( $tags_list && ! is_wp_error( $tags_list ) ) {
4341
/* translators: 1: Categories list, 2: Tag list, 3: Permalink, 4: Post title, 5: Author name, 6: Author URL. */

src/wp-content/themes/twentyeleven/content.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@
5555

5656
<?php if ( is_object_in_taxonomy( get_post_type(), 'category' ) ) : // Hide category text when not supported. ?>
5757
<?php
58-
/* translators: Used between list items, there is a space after the comma. */
59-
$categories_list = get_the_category_list( __( ', ', 'twentyeleven' ) );
58+
$categories_list = get_the_category_list( wp_get_list_item_separator() );
6059

6160
if ( $categories_list ) :
6261
?>
@@ -72,8 +71,7 @@
7271

7372
<?php if ( is_object_in_taxonomy( get_post_type(), 'post_tag' ) ) : // Hide tag text when not supported. ?>
7473
<?php
75-
/* translators: Used between list items, there is a space after the comma. */
76-
$tags_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) );
74+
$tags_list = get_the_tag_list( '', wp_get_list_item_separator() );
7775

7876
if ( $tags_list && ! is_wp_error( $tags_list ) ) :
7977
if ( $show_sep ) :

src/wp-content/themes/twentyeleven/functions.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,3 +929,17 @@ function twentyeleven_skip_link() {
929929
}
930930
}
931931
add_action( 'wp_body_open', 'twentyeleven_skip_link', 5 );
932+
933+
if ( ! function_exists( 'wp_get_list_item_separator' ) ) :
934+
/**
935+
* Retrieves the list item separator based on the locale.
936+
*
937+
* Added for backward compatibility to support pre-6.0.0 WordPress versions.
938+
*
939+
* @since 6.0.0
940+
*/
941+
function wp_get_list_item_separator() {
942+
/* translators: Used between list items, there is a space after the comma. */
943+
return __( ', ', 'twentyeleven' );
944+
}
945+
endif;

src/wp-content/themes/twentynineteen/functions.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,20 @@ function twentynineteen_setup() {
182182
endif;
183183
add_action( 'after_setup_theme', 'twentynineteen_setup' );
184184

185+
if ( ! function_exists( 'wp_get_list_item_separator' ) ) :
186+
/**
187+
* Retrieves the list item separator based on the locale.
188+
*
189+
* Added for backward compatibility to support pre-6.0.0 WordPress versions.
190+
*
191+
* @since 6.0.0
192+
*/
193+
function wp_get_list_item_separator() {
194+
/* translators: Used between list items, there is a space after the comma. */
195+
return __( ', ', 'twentynineteen' );
196+
}
197+
endif;
198+
185199
/**
186200
* Register widget area.
187201
*

0 commit comments

Comments
 (0)