Make WordPress Core

Changeset 52929

Timestamp:
03/13/2022 08:01:05 PM (2 years ago)
Author:
audrasjb
Message:

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.

Location:
trunk/src
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-media-list-table.php

    r52842 r52929  
    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>';
  • trunk/src/wp-admin/includes/class-wp-posts-list-table.php

    r52215 r52929  
    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>';
  • trunk/src/wp-content/themes/twentyeleven/content-featured.php

    r47886 r52929  
    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 ) ) {
     
    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() ),
  • trunk/src/wp-content/themes/twentyeleven/content-gallery.php

    r47886 r52929  
    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 ) :
     
    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 ) ) :
  • trunk/src/wp-content/themes/twentyeleven/content-image.php

    r47886 r52929  
    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 ) :
     
    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 ) ) :
  • trunk/src/wp-content/themes/twentyeleven/content-quote.php

    r47886 r52929  
    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 ) :
     
    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 ) ) :
  • trunk/src/wp-content/themes/twentyeleven/content-single.php

    r47886 r52929  
    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 ) ) {
  • trunk/src/wp-content/themes/twentyeleven/content.php

    r47886 r52929  
    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 ) :
     
    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 ) ) :
  • trunk/src/wp-content/themes/twentyeleven/functions.php

    r51103 r52929  
    930930}
    931931add_action( 'wp_body_open', 'twentyeleven_skip_link', 5 );
     932
     933
     934
     935
     936
     937
     938
     939
     940
     941
     942
     943
     944
     945
  • trunk/src/wp-content/themes/twentynineteen/functions.php

    r49901 r52929  
    183183add_action( 'after_setup_theme', 'twentynineteen_setup' );
    184184
     185
     186
     187
     188
     189
     190
     191
     192
     193
     194
     195
     196
     197
     198
    185199/**
    186200 * Register widget area.
  • trunk/src/wp-content/themes/twentynineteen/inc/template-tags.php

    r52182 r52929  
    8383            twentynineteen_posted_on();
    8484
    85             /* translators: Used between list items, there is a space after the comma. */
    86             $categories_list = get_the_category_list( __( ', ', 'twentynineteen' ) );
     85            $categories_list = get_the_category_list( wp_get_list_item_separator() );
    8786            if ( $categories_list ) {
    8887                printf(
     
    9594            }
    9695
    97             /* translators: Used between list items, there is a space after the comma. */
    98             $tags_list = get_the_tag_list( '', __( ', ', 'twentynineteen' ) );
     96            $tags_list = get_the_tag_list( '', wp_get_list_item_separator() );
    9997            if ( $tags_list && ! is_wp_error( $tags_list ) ) {
    10098                printf(
  • trunk/src/wp-content/themes/twentyseventeen/functions.php

    r51607 r52929  
    648648}
    649649
     650
     651
     652
     653
     654
     655
     656
     657
     658
     659
     660
     661
     662
     663
    650664/**
    651665 * Implement the Custom Header feature.
  • trunk/src/wp-content/themes/twentyseventeen/inc/template-tags.php

    r49120 r52929  
    6363    function twentyseventeen_entry_footer() {
    6464
    65         /* translators: Used between list items, there is a space after the comma. */
    66         $separate_meta = __( ', ', 'twentyseventeen' );
     65        $separate_meta = wp_get_list_item_separator();
    6766
    6867        // Get Categories for posts.
  • trunk/src/wp-content/themes/twentythirteen/functions.php

    r52928 r52929  
    439439add_action( 'widgets_init', 'twentythirteen_widgets_init' );
    440440
     441
     442
     443
     444
     445
     446
     447
     448
     449
     450
     451
     452
     453
     454
    441455if ( ! function_exists( 'twentythirteen_paging_nav' ) ) :
    442456    /**
     
    518532        }
    519533
    520         /* translators: Used between list items, there is a space after the comma. */
    521         $categories_list = get_the_category_list( __( ', ', 'twentythirteen' ) );
     534        $categories_list = get_the_category_list( wp_get_list_item_separator() );
    522535        if ( $categories_list ) {
    523536            echo '<span class="categories-links">' . $categories_list . '</span>';
    524537        }
    525538
    526         /* translators: Used between list items, there is a space after the comma. */
    527         $tags_list = get_the_tag_list( '', __( ', ', 'twentythirteen' ) );
     539        $tags_list = get_the_tag_list( '', wp_get_list_item_separator() );
    528540        if ( $tags_list && ! is_wp_error( $tags_list ) ) {
    529541            echo '<span class="tags-links">' . $tags_list . '</span>';
  • trunk/src/wp-content/themes/twentytwelve/functions.php

    r51967 r52929  
    384384}
    385385add_action( 'widgets_init', 'twentytwelve_widgets_init' );
     386
     387
     388
     389
     390
     391
     392
     393
     394
     395
     396
     397
     398
     399
    386400
    387401if ( ! function_exists( 'twentytwelve_content_nav' ) ) :
     
    503517     */
    504518    function twentytwelve_entry_meta() {
    505         /* translators: Used between list items, there is a space after the comma. */
    506         $categories_list = get_the_category_list( __( ', ', 'twentytwelve' ) );
    507 
    508         /* translators: Used between list items, there is a space after the comma. */
    509         $tags_list = get_the_tag_list( '', __( ', ', 'twentytwelve' ) );
     519        $categories_list = get_the_category_list( wp_get_list_item_separator() );
     520
     521        $tags_list = get_the_tag_list( '', wp_get_list_item_separator() );
    510522
    511523        $date = sprintf(
  • trunk/src/wp-content/themes/twentytwentyone/functions.php

    r52191 r52929  
    641641}
    642642add_action( 'wp_footer', 'twentytwentyone_add_ie_class' );
     643
     644
     645
     646
     647
     648
     649
     650
     651
     652
     653
     654
     655
     656
  • trunk/src/wp-content/themes/twentytwentyone/inc/template-tags.php

    r50233 r52929  
    101101                echo '<div class="post-taxonomies">';
    102102
    103                 /* translators: Used between list items, there is a space after the comma. */
    104                 $categories_list = get_the_category_list( __( ', ', 'twentytwentyone' ) );
     103                $categories_list = get_the_category_list( wp_get_list_item_separator() );
    105104                if ( $categories_list ) {
    106105                    printf(
     
    111110                }
    112111
    113                 /* translators: Used between list items, there is a space after the comma. */
    114                 $tags_list = get_the_tag_list( '', __( ', ', 'twentytwentyone' ) );
     112                $tags_list = get_the_tag_list( '', wp_get_list_item_separator() );
    115113                if ( $tags_list ) {
    116114                    printf(
     
    145143                echo '<div class="post-taxonomies">';
    146144
    147                 /* translators: Used between list items, there is a space after the comma. */
    148                 $categories_list = get_the_category_list( __( ', ', 'twentytwentyone' ) );
     145                $categories_list = get_the_category_list( wp_get_list_item_separator() );
    149146                if ( $categories_list ) {
    150147                    printf(
     
    155152                }
    156153
    157                 /* translators: Used between list items, there is a space after the comma. */
    158                 $tags_list = get_the_tag_list( '', __( ', ', 'twentytwentyone' ) );
     154                $tags_list = get_the_tag_list( '', wp_get_list_item_separator() );
    159155                if ( $tags_list ) {
    160156                    printf(
  • trunk/src/wp-includes/class-wp-locale.php

    r52652 r52929  
    9595     */
    9696    public $number_format;
     97
     98
     99
     100
     101
     102
     103
     104
    97105
    98106    /**
     
    210218        $this->number_format['decimal_point'] = ( 'number_format_decimal_point' === $decimal_point ) ? '.' : $decimal_point;
    211219
     220
     221
     222
    212223        // Set text direction.
    213224        if ( isset( $GLOBALS['text_direction'] ) ) {
     
    367378        __( 'F j, Y g:i a' );
    368379    }
     380
     381
     382
     383
     384
     385
     386
     387
     388
     389
     390
    369391}
  • trunk/src/wp-includes/class-wp-theme.php

    r52652 r52929  
    925925                static $comma = null;
    926926                if ( ! isset( $comma ) ) {
    927                     /* translators: Used between list items, there is a space after the comma. */
    928                     $comma = __( ', ' );
     927                    $comma = wp_get_list_item_separator();
    929928                }
    930929                $value = implode( $comma, $value );
  • trunk/src/wp-includes/functions.php

    r52832 r52929  
    83728372    return abs( (float) $expected - (float) $actual ) <= $precision;
    83738373}
     8374
     8375
     8376
     8377
     8378
     8379
     8380
     8381
     8382
     8383
     8384
     8385
     8386
     8387
Note: See TracChangeset for help on using the changeset viewer.