Opened 7 years ago
Closed 6 years ago
#44599 closed enhancement (invalid)
Add translator notes to _post_states via _x
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | I18N | Keywords: | has-patch needs-unit-tests needs-refresh |
Focuses: | administration | Cc: |
Description
Hello,
To assist translators it would be nice to provide context for _post_states strings. This would help in cases such as #44130 where the case depends on the context of where the string appears in the UI.
Speaking specifically of these strings;
https://core.trac.wordpress.org/browser/branches/4.9/src/wp-admin/includes/template.php?marks=1739-1779#L1739
1747 $post_states['protected'] = __('Password protected'); 1749 $post_states['private'] = __('Private'); 1752 $post_states[] = __( 'Customization Draft' ); 1754 $post_states['draft'] = __( 'Draft' ); 1757 $post_states[] = __( 'Customization Draft' ); 1760 $post_states['pending'] = _x('Pending', 'post status'); 1762 $post_states['sticky'] = __('Sticky'); 1765 $post_states['scheduled'] = __( 'Scheduled' ); 1770 $post_states['page_on_front'] = __( 'Front Page' ); 1774 $post_states['page_for_posts'] = __( 'Posts Page' ); 1779 $post_states['page_for_privacy_policy'] = __( 'Privacy Policy Page' );
The one pending status does have context via _x so the rest could be done for consistency.
As all items in the function are post stati could simply create a $context = 'post_status';
variable to use throughout the entire function.
$context = 'post_status';
$post_statesprotected? = _x('Password protected', $context);
All the best,
Cheers
Attachments (2)
Change History (16)
#1
@
7 years ago
- Focuses administration added
- Keywords needs-patch good-first-bug added
- Milestone changed from Awaiting Review to Future Release
- Version trunk deleted
#2
@
7 years ago
$context var was created and subsequently utilized throughout the function utilizing _x to create standardized output so as to provide greater clarification for those using languages other than English.
-Also-
This is my first time posting here at the Wordpress Core, so please forgive me if I've made any error(s). I'm here to learn and am grateful to any input anyone can provide. Thanks ahead of time :)
This ticket was mentioned in Slack in #polyglots by garrett-eclipse. View the logs.
7 years ago
#4
@
7 years ago
Thanks @cc0a appreciate the contribution and welcome to core.
You can find more resources and guides here - https://make.wordpress.org/core/handbook/contribute/
Your patch looks pretty good, I just asked in #polyglots on Slack if the $context is better as 'post_status' or 'Post Status' so we'll see what the translators think.
You'll want to refresh your patch removing the additional newline at L1729. And possibly L1770 as it seems present in the latest so doing a patch refresh might remove it.
More on patches - https://make.wordpress.org/core/handbook/tutorials/working-with-patches/#creating-a-patch
Note: I often see patches submitted with the ticket number like 44599.patch so they're tied by name.
Thanks again
#5
@
7 years ago
Hi @cc0a can you update the $context string from 'post_status' to 'Post Status' as recommended by @presskopp in the #polyglots channel. I agree this makes it plain and clear for translators. Thanks
#6
@
7 years ago
I'll make the requested changes and have a new patch submitted tonight. Thank you very much for your suggestions and provided resources, Garret-Eclipse, I really appreciate it!!
#7
@
7 years ago
Alright, I believe I've updated it correctly. Thanks again @garrett-eclipse for the feedback!
#8
@
7 years ago
- Keywords has-patch needs-testing needs-unit-tests i18n-change added; needs-patch good-first-bug removed
- Milestone changed from Future Release to 4.9.9
You're welcome. The updated patch looks great, going to update the workflow and see if this can land in 4.9.9
#9
@
6 years ago
- Keywords needs-refresh added; needs-testing removed
Hey @ccoa, thanks for the contribution!
A few points of feedback on the latest patch.
First, although it is simpler to use a $context
variable for all _x()
calls that share the same context, variables cannot be used in translation functions. The translation tools do not run within the context of PHP, so they have no way to determine what the value of the $context
variable is when compiling the list of strings for translators.
Second, it seems that the patch does not apply correctly. When creating a patch, it should be created against a development copy of WordPress. Check out the page about Installing WordPress Locally for some pointers on that.
Patch to add $context variable to post states function.