Make WordPress Core


Ignore:
Timestamp:
03/13/2022 08:01:05 PM (3 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentythirteen/functions.php

    r52928 r52929  
    439439add_action( 'widgets_init', 'twentythirteen_widgets_init' );
    440440
     441if ( ! function_exists( 'wp_get_list_item_separator' ) ) :
     442    /**
     443     * Retrieves the list item separator based on the locale.
     444     *
     445     * Added for backward compatibility to support pre-6.0.0 WordPress versions.
     446     *
     447     * @since 6.0.0
     448     */
     449    function wp_get_list_item_separator() {
     450        /* translators: Used between list items, there is a space after the comma. */
     451        return __( ', ', 'twentythirteen' );
     452    }
     453endif;
     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>';
Note: See TracChangeset for help on using the changeset viewer.