Skip to content

Commit

Permalink
I18N: Improve translator comments for strings containing date formats.
Browse files Browse the repository at this point in the history
Adds translator comments where absent and changes code style so that
comments are attached to the right strings during string extraction.

Props NekoJonez.
Fixes #59947

git-svn-id: https://develop.svn.wordpress.org/trunk@57136 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
swissspidy committed Nov 26, 2023
1 parent cd5cf79 commit bc4eb46
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 9 deletions.
17 changes: 13 additions & 4 deletions src/wp-admin/edit-form-advanced.php
Original file line number Diff line number Diff line change
Expand Up @@ -649,11 +649,20 @@
echo '<span id="last-edit">';
$last_user = get_userdata( get_post_meta( $post->ID, '_edit_last', true ) );
if ( $last_user ) {
/* translators: 1: Name of most recent post author, 2: Post edited date, 3: Post edited time. */
printf( __( 'Last edited by %1$s on %2$s at %3$s' ), esc_html( $last_user->display_name ), mysql2date( __( 'F j, Y' ), $post->post_modified ), mysql2date( __( 'g:i a' ), $post->post_modified ) );
printf(
/* translators: 1: Name of most recent post author, 2: Post edited date, 3: Post edited time. */
__( 'Last edited by %1$s on %2$s at %3$s' ),
esc_html( $last_user->display_name ),
mysql2date( __( 'F j, Y' ), $post->post_modified ),
mysql2date( __( 'g:i a' ), $post->post_modified )
);
} else {
/* translators: 1: Post edited date, 2: Post edited time. */
printf( __( 'Last edited on %1$s at %2$s' ), mysql2date( __( 'F j, Y' ), $post->post_modified ), mysql2date( __( 'g:i a' ), $post->post_modified ) );
printf(
/* translators: 1: Post edited date, 2: Post edited time. */
__( 'Last edited on %1$s at %2$s' ),
mysql2date( __( 'F j, Y' ), $post->post_modified ),
mysql2date( __( 'g:i a' ), $post->post_modified )
);
}
echo '</span>';
}
Expand Down
9 changes: 7 additions & 2 deletions src/wp-admin/includes/ajax-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1628,8 +1628,13 @@ function wp_ajax_add_meta() {
$post_data['post_type'] = $post->post_type;
$post_data['post_status'] = 'draft';
$now = time();
/* translators: 1: Post creation date, 2: Post creation time. */
$post_data['post_title'] = sprintf( __( 'Draft created on %1$s at %2$s' ), gmdate( __( 'F j, Y' ), $now ), gmdate( __( 'g:i a' ), $now ) );

$post_data['post_title'] = sprintf(
/* translators: 1: Post creation date, 2: Post creation time. */
__( 'Draft created on %1$s at %2$s' ),
gmdate( __( 'F j, Y' ), $now ),
gmdate( __( 'g:i a' ), $now )
);

$pid = edit_post( $post_data );

Expand Down
2 changes: 1 addition & 1 deletion src/wp-admin/includes/meta-boxes.php
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ function attachment_submit_meta_box( $post ) {
<span id="timestamp">
<?php
$uploaded_on = sprintf(
/* translators: Publish box date string. 1: Date, 2: Time. See https://www.php.net/manual/datetime.format.php */
/* translators: Publish box date string. 1: Date, 2: Time. */
__( '%1$s at %2$s' ),
/* translators: Publish box date format, see https://www.php.net/manual/datetime.format.php */
date_i18n( _x( 'M j, Y', 'publish box date format' ), strtotime( $post->post_date ) ),
Expand Down
11 changes: 9 additions & 2 deletions src/wp-admin/update-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -1105,8 +1105,15 @@ function do_undismiss_core_update() {
echo '</h2>';

echo '<p class="update-last-checked">';
/* translators: 1: Date, 2: Time. */
printf( __( 'Last checked on %1$s at %2$s.' ), date_i18n( __( 'F j, Y' ), $last_update_check ), date_i18n( __( 'g:i a T' ), $last_update_check ) );

printf(
/* translators: 1: Date, 2: Time. */
__( 'Last checked on %1$s at %2$s.' ),
/* translators: Last update date format. See https://www.php.net/manual/datetime.format.php */
date_i18n( __( 'F j, Y' ), $last_update_check ),
/* translators: Last update time format. See https://www.php.net/manual/datetime.format.php */
date_i18n( __( 'g:i a T' ), $last_update_check )
);
echo ' <a href="' . esc_url( self_admin_url( 'update-core.php?force-check=1' ) ) . '">' . __( 'Check again.' ) . '</a>';
echo '</p>';

Expand Down
3 changes: 3 additions & 0 deletions src/wp-includes/general-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -1715,12 +1715,15 @@ function get_the_archive_title() {
$title = get_the_author();
$prefix = _x( 'Author:', 'author archive title prefix' );
} elseif ( is_year() ) {
/* translators: See https://www.php.net/manual/datetime.format.php */
$title = get_the_date( _x( 'Y', 'yearly archives date format' ) );
$prefix = _x( 'Year:', 'date archive title prefix' );
} elseif ( is_month() ) {
/* translators: See https://www.php.net/manual/datetime.format.php */
$title = get_the_date( _x( 'F Y', 'monthly archives date format' ) );
$prefix = _x( 'Month:', 'date archive title prefix' );
} elseif ( is_day() ) {
/* translators: See https://www.php.net/manual/datetime.format.php */
$title = get_the_date( _x( 'F j, Y', 'daily archives date format' ) );
$prefix = _x( 'Day:', 'date archive title prefix' );
} elseif ( is_tax( 'post_format' ) ) {
Expand Down
2 changes: 2 additions & 0 deletions src/wp-includes/theme-compat/sidebar.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
/* translators: 1: Site link, 2: Archive date. */
__( 'You are currently browsing the %1$s blog archives for the day %2$s.' ),
sprintf( '<a href="%1$s/">%2$s</a>', get_bloginfo( 'url' ), get_bloginfo( 'name' ) ),
/* translators: Daily archives date format. See https://www.php.net/manual/datetime.format.php */
get_the_time( __( 'l, F jS, Y' ) )
);
?>
Expand All @@ -68,6 +69,7 @@
/* translators: 1: Site link, 2: Archive month. */
__( 'You are currently browsing the %1$s blog archives for %2$s.' ),
sprintf( '<a href="%1$s/">%2$s</a>', get_bloginfo( 'url' ), get_bloginfo( 'name' ) ),
/* translators: Monthly archives date format. See https://www.php.net/manual/datetime.format.php */
get_the_time( __( 'F, Y' ) )
);
?>
Expand Down

0 comments on commit bc4eb46

Please sign in to comment.