Make WordPress Core


Ignore:
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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-locale.php

    r52652 r52929  
    9595     */
    9696    public $number_format;
     97
     98    /**
     99     * The separator string used for localizing list item separator.
     100     *
     101     * @since 6.0.0
     102     * @var string
     103     */
     104    public $list_item_separator;
    97105
    98106    /**
     
    210218        $this->number_format['decimal_point'] = ( 'number_format_decimal_point' === $decimal_point ) ? '.' : $decimal_point;
    211219
     220        /* translators: used between list items, there is a space after the comma */
     221        $this->list_item_separator = __( ', ' );
     222
    212223        // Set text direction.
    213224        if ( isset( $GLOBALS['text_direction'] ) ) {
     
    367378        __( 'F j, Y g:i a' );
    368379    }
     380
     381    /**
     382     * Retrieve the localized list item separator.
     383     *
     384     * @since 6.0.0
     385     *
     386     * @return string Localized list item separator.
     387     */
     388    public function get_list_item_separator() {
     389        return $this->list_item_separator;
     390    }
    369391}
Note: See TracChangeset for help on using the changeset viewer.