[wp-trac] [WordPress Trac] #29849: Better human_time_diff()

WordPress Trac noreply at wordpress.org
Wed Jun 24 20:00:01 UTC 2015


#29849: Better human_time_diff()
-------------------------+------------------------------
 Reporter:  kovshenin    |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Date/Time    |     Version:
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |     Focuses:
-------------------------+------------------------------

Comment (by akirk):

 Thank you very much for picking up the ball! I don't want to start a edit
 war in the Codex, so maybe we can discuss here: in general I think the
 context is not the place to explain variables, this should be done in a
 `/* translators: */` comment.

 Also I am unsure if adding a text-domain to the example is really helpful,
 part of the idea of `wp_natural_time()` is to leverage the common text
 usage (and its translation) of "%s ago".

 Last but not least, in my opinion the "internationalized" version should
 be the only way to use it, we get the "%s ago" string in a translated
 version for free through WordPress, there is no need to advocate the usage
 of the concattenating version.

 So I'd suggest to simply change the code example in the codex to this:

   To print an entry's time ("2 days ago"):
   `<?php printf( __( '%s ago' ), human_time_diff( get_the_time('U'),
 current_time('timestamp') ) ); ?>`
   For comments:
   `<?php printf( __( '%s ago' ), human_time_diff( get_comment_time('U'),
 current_time('timestamp') ) ); ?>`

--
Ticket URL: <https://core.trac.wordpress.org/ticket/29849#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list