#39733 closed enhancement (fixed)
List item separator should be a WP_Locale property
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 6.0 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | I18N | Keywords: | good-first-bug has-patch commit has-screenshots needs-dev-note |
| Focuses: | Cc: |
Description
Currently, some (most?) themes have a translatable list item separator for displaying a list of categories or tags. See an example in Twenty Seventeen:
/* translators: used between list items, there is a space after the comma */ $separate_meta = __( ', ', 'twentyseventeen' );
One of ru_RU translation team contributors made a point that list item separator is a locale property, and it doesn't make much sense to translate it separately in multiple projects.
We could probably add it as a property of WP_Locale class, in addition to ::number_format['thousands_sep'] and ::number_format['decimal_point'], and there should be a public function like number_format_i18n(), e.g. get_list_item_separator(), for plugins and themes to use. Thoughts?
Attachments (5)
Change History (21)
#2
@
4 years ago
- Keywords needs-patch good-first-bug added
- Milestone changed from Awaiting Review to Future Release
#3
@
4 years ago
- Keywords has-patch added; needs-patch removed
@swissspidy @SergeyBiryukov I've uploaded the initial version of the patch.
Are you able to tell if I'm going in the correct direction?
#4
@
4 years ago
Just noting that I don't think it will be possible to change the default themes to use this new method because they need to remain compatible with the version of WordPress where they were introduced. A compatibility layer in each theme could be an option.
#5
@
4 years ago
Thanks for the patch! The WP_Locale part looks good at a glance.
For the usage though, I think we'd want to avoid using the $wp_locale global in all those instances, and just wrap this in a function like wp_get_list_item_separator() that would still call $wp_locale->get_list_item_separator() internally.
As noted above, we should also think about backward compatibility for bundled themes.
#6
@
4 years ago
@johnbillion @SergeyBiryukov I uploaded the second version of the patch.
Changes:
- Added wrapper function --
wp_get_list_item_separator()-- forWP_Locale::get_list_item_separator. - Replaced
$wp_locale->get_list_item_separator()calls withwp_get_list_item_separator()calls. - Added a "compatibility layer" for the twentyeleven theme. Does that look correct?
This ticket was mentioned in Slack in #core by rsiddharth. View the logs.
4 years ago
This ticket was mentioned in PR #2405 on WordPress/wordpress-develop by audrasjb.
4 years ago
#9
Trac ticket: https://core.trac.wordpress.org/ticket/39733
#10
@
4 years ago
The above PR refreshes the previous patch against trunk and updates @since mentions. It also add again a removed translator comment.
#11
@
4 years ago
- Owner set to audrasjb
- Status changed from new to accepted
The patch works fine on my side using default themes or navigating through admin screens.
Self assigning for commit consideration.
#12
@
4 years ago
- Keywords commit has-screenshots added
Manual tests are going well. Marking for commit.
#14
@
4 years ago
- Keywords needs-dev-note added
This change deserves a dev note or at least a mention in the Misc changes dev note.
4 years ago
#15
Committed in https://core.trac.wordpress.org/changeset/52929
Sounds useful. Besides the default themes there are three instances of
__( ', ' )being used in core. Perhaps more when counting instances ofimplode( ', ', … )that could make use of a translatable list item separator.