Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PostScheduleLabel: Updated the component to return a translatable string for postpublish component. #67614

Conversation

CoderAbhinav
Copy link

Description:

  1. Added a prop to return a proper translatable string for post publish panel.
  2. This doesn't affect any existing usage of the component.

What?

As mentioned in the #67487 issue, we need to break the string mentioned here

export function getPostScheduleLabel(
dateAttribute,
{ isFloating = false, now = new Date() } = {}
) {
if ( ! dateAttribute || isFloating ) {
return __( 'Immediately' );
}
// If the user timezone does not equal the site timezone then using words
// like 'tomorrow' is confusing, so show the full date.
if ( ! isTimezoneSameAsSiteTimezone( now ) ) {
return getFullPostScheduleLabel( dateAttribute );
}
const date = getDate( dateAttribute );
if ( isSameDay( date, now ) ) {
return sprintf(
// translators: %s: Time of day the post is scheduled for.
__( 'Today at %s' ),
// translators: If using a space between 'g:i' and 'a', use a non-breaking space.
dateI18n( _x( 'g:i\xa0a', 'post schedule time format' ), date )
);
}
const tomorrow = new Date( now );
tomorrow.setDate( tomorrow.getDate() + 1 );
if ( isSameDay( date, tomorrow ) ) {
return sprintf(
// translators: %s: Time of day the post is scheduled for.
__( 'Tomorrow at %s' ),
// translators: If using a space between 'g:i' and 'a', use a non-breaking space.
dateI18n( _x( 'g:i\xa0a', 'post schedule time format' ), date )
);
}

Such that translators can easily translate the string.
So I have updated the usePostScheduleLabel with a prop for which will be used to identify where we are using this, so that if it's used in the Post Publish Panel, it will return an output which says "It will go live on %s", this allows the translators to translate the string for most of the langugages, providing them better context.

Why?

This was mentioned in the following issue #67487 and also suggested to break the string so it will be easy for translations.

How?

Basically we have broken down the initial string such that now it will be returning a full label with string for the provided post publish panel, while it will work normally for the rest of the instances.

Testing Instructions

  1. Go to Posts > Add New
  2. Write a new post
  3. Schedule it to be published tomorrow
  4. See the post-publish panel.

Testing Instructions for Keyboard

Screenshots or screencast

Screenshot 2024-12-05 at 2 48 04 PM

…ing for postpublish component.

Description:
1. Added a prop to return a proper translatable string for post publish panel.
2. This doesn't affect any existing usage of the component.
Copy link

github-actions bot commented Dec 5, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: CoderAbhinav <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link

github-actions bot commented Dec 5, 2024

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @CoderAbhinav! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant