WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 2 years ago

Last modified 7 weeks ago

#18495 closed defect (bug) (duplicate)

human_time_diff() localization

Reported by: pavelevap Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.2.1
Component: I18N Keywords: has-patch
Focuses: Cc:

Description

Using human_time_diff() function for different purposes, there is big localization problem for example for Czech.

We can use this function in two ways:

1) "Post is 5 days old." - "5 days" (EN) = "5 dní" (CZ)

2) "Post was published 5 days ago." - "5 days" (EN) = "5 dny" (CZ)

English language has only one phrase, but Czech (and others) are much more complicated. For example, WordPress uses this function for list of posts in administration (5 days ago). But new bbPress plugin uses this function for Freshness (that means 5 days). And in this case it is nonsense in Czech language...

I could not find any solution...

Attachments (1)

18495.patch (992 bytes) - added by SergeyBiryukov 3 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 gautamgupta3 years ago

  • Cc gautamgupta added

comment:2 in reply to: ↑ description SergeyBiryukov3 years ago

Replying to pavelevap:

But new bbPress plugin uses this function for Freshness (that means 5 days).

If this case is the only problem so far, I'd probably translate "Freshness" as an equivalent of "Updated" , so that "5 days ago" would make sense in that column too. Isn't it an acceptable workaround?

comment:3 follow-up: pavelevap3 years ago

SergeyBiryukov: Yes, it would be partial solution, but it is not possible to change "5 days" to "5 days ago" in bbPress and so translation is nonsense even if I change "Freshness". I will try to use ngettext hook to change it (I am not sure if it can be done conditionally only for bbPress plugin?).

But generally, it would be helpfull to have for example optional parameter (or something else) to use human_time_diff() in different ways. It is not always possible to change meaning in which it is used in different plugins (or use ngettext filter). There are two common meanings (old and ago) which should be probably handled differently...

SergeyBiryukov3 years ago

comment:4 in reply to: ↑ 3 ; follow-up: SergeyBiryukov3 years ago

  • Keywords has-patch added

Replying to pavelevap:

it is not possible to change "5 days" to "5 days ago" in bbPress

In the admin, it says "5 days ago" in the Fresness column, so I didn't notice at first that it says "5 days" on the frontend.

I will try to use ngettext hook to change it

There's bbp_get_topic_freshness_link filter, which can be more appropriate.

But generally, it would be helpfull to have for example optional parameter (or something else) to use human_time_diff() in different ways.

18495.patch adds a filter for human_time_diff().

comment:5 pavelevap3 years ago

Thank you for patch!

I tried bbPress filters, but using filter bbp_get_topic_freshness_link is only for topics and not for forums and there are also other filters, for example bbp_get_forum_freshness_link (for forum), etc. Digging deeper I found also function (and filter) bbp_get_time_since, but this filter does not work for me, maybe because there is hardcoded function in apply_filters()?

apply_filters( 'bbp_get_time_since', human_time_diff( $time, current_time( 'timestamp' ) ), $time );

But this discussion should be probably on bbPress Trac...

comment:6 Viper007Bond2 years ago

  • Resolution set to duplicate
  • Status changed from new to closed

human_time_diff() is being re-written in #9272 so I'm going to close this ticket in favor of that one so we can keep the discussion all in one place.

comment:7 SergeyBiryukov2 years ago

  • Milestone Awaiting Review deleted

comment:8 in reply to: ↑ 4 SergeyBiryukov7 weeks ago

Replying to SergeyBiryukov:

18495.patch adds a filter for human_time_diff().

Follow-up: #27271

Note: See TracTickets for help on using tickets.