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

Date format 'F jS, Y' is not correct for non English languages #55

Open
giorgioriccardi opened this issue Jun 22, 2015 · 0 comments
Open

Comments

@giorgioriccardi
Copy link
Contributor

Hi Morten,
I have a WP Italian site that uses Simone. The date was printed like in English st, nd or th in the 1st, 2nd or 15th
Since you smartly wrote the function pluggable if ( ! function_exists( 'simone_posted_on' ) ) : I've created a function in my child theme that overrides it:

 * Remove S from the date format for non English languages
 * [the English suffix for the day of the month st, nd or th in the 1st, 2nd or 15th]
 * http://php.net/manual/en/function.date.php
 */
function simone_posted_on() {
  $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time>';
  if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
    $time_string .= '<time class="updated" datetime="%3$s">%4$s</time>';
  }

  $time_string = sprintf( $time_string,
    esc_attr( get_the_date( 'c' ) ),
    // esc_html( get_the_date( _x('F jS, Y', 'Public posted on date', 'simone') ) ), //original code
    esc_html( get_the_date( _x('F j, Y', 'Public posted on date', 'simone') ) ), //removed S
    esc_attr( get_the_modified_date( 'c' ) ),
    // esc_html( get_the_modified_date( _x('F jS, Y', 'Public modified on date', 'simone') ) ) //original code
    esc_html( get_the_modified_date( _x('F j, Y', 'Public modified on date', 'simone') ) ) //removed S
  );
        // Translators: Text wrapped in mobile-hide class is hidden on wider screens.
  printf( _x( '<span class="byline">Written by %1$s</span><span class="mobile-hide"> on </span><span class="posted-on">%2$s</span><span class="mobile-hide">.</span>', 'mobile-hide class is used to hide connecting elements like "on" and "." on wider screens.', 'simone' ),
    sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s">%2$s</a></span>',
      esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
      esc_html( get_the_author() )
    ),
                sprintf( '<a href="%1$s" rel="bookmark">%2$s</a>',
      esc_url( get_permalink() ),
      $time_string
    )
  );
}

This works, but unfortunately it also affects the English version. I was wondering if there is a way to implement date i18n into Simone core or child-theme function or if you can think of another solution.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant