Make WordPress Core

Opened 7 years ago

Closed 6 years ago

#44599 closed enhancement (invalid)

Add translator notes to _post_states via _x

Reported by: garrett-eclipse's profile garrett-eclipse 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)

context.patch (2.3 KB) - added by cc0a 7 years ago.
Patch to add $context variable to post states function.
44599.patch (2.3 KB) - added by cc0a 7 years ago.

Download all attachments as: .zip

Change History (16)

#1 @johnbillion
7 years ago

  • Focuses administration added
  • Keywords needs-patch good-first-bug added
  • Milestone changed from Awaiting Review to Future Release
  • Version trunk deleted

@cc0a
7 years ago

Patch to add $context variable to post states function.

#2 @cc0a
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 :)

Last edited 7 years ago by cc0a (previous) (diff)

This ticket was mentioned in Slack in #polyglots by garrett-eclipse. View the logs.


7 years ago

#4 @garrett-eclipse
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 @garrett-eclipse
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 @cc0a
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!!

@cc0a
7 years ago

#7 @cc0a
7 years ago

Alright, I believe I've updated it correctly. Thanks again @garrett-eclipse for the feedback!

#8 @garrett-eclipse
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 @desrosj
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.

#11 @SergeyBiryukov
6 years ago

  • Keywords i18n-change removed

#12 @SergeyBiryukov
6 years ago

(The i18n-change tag is used after string freeze, which generally happens at RC stage, to notify translators about additional string changes.)

#13 @pento
6 years ago

  • Milestone changed from 4.9.9 to Future Release

#14 @garrett-eclipse
6 years ago

  • Milestone Future Release deleted
  • Resolution set to invalid
  • Status changed from new to closed

This is being completely rewritten in #14981 so closing in favour of the work done there.

Note: See TracTickets for help on using tickets.