Project

General

Profile

Actions

Feature proposal #8092

closed

API: Date class: Add human-readable PHP output of "time ago" time scale

Added by beat almost 4 years ago. Updated almost 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Start date:
13 July 2020
Due date:
% Done:

100%

Estimated time:

Related issues 1 (0 open1 closed)

Related to CB Paid Subscriptions - Feature proposal #8079: Internationalization: Better pluralization of time-periodsClosedbeat30 June 2020

Actions
Actions #1

Updated by beat almost 4 years ago

Actions #2

Updated by beat almost 4 years ago

Instructions / Reminder for translators:

CB Pluralization in translations (with one numeric substitution, e.g. "[X]" can happen as one of following (the indexed form being prefered):

  • interval: {0} There are no apples|{1} There is one apple|]1,Inf] There are [X] apples
  • indexed: There is one apple|There are [X] apples

For intervals: intervals are like in maths:

  • [2,5] includes 2,3,4,5,
  • ]2,5] includes 3,4,5,
  • ]2,5[ includes 3 and 4.
  • Inf and -Inf are infinites.

For indexed:

The two methods can also be mixed:

  • {0} There are no apples|one: There is one apple|more: There are count apples

Regarding this feature:

This feature introduces e.g. this translation string:

'X_YEARS' => "one year|[X] years" 

2 examples: English:

0 hours
1 hour
2 hours
...

Translates in French (notice that 0 is singular) to:

0 heure
1 heure
2 heures
3 heures
...

Which has only 2 cases:

nplurals=2; plural=(n > 1);

But as first case has many cases as it's >1, the string must be containing the number:

'X_YEARS' => "[X] heure|[X] heures" 

Alternatively to have nicer translations, it could be using a mix of the interval enumerated form for litteral exceptions, and indexed form for the numeric cases:

'X_YEARS' => "{0} aucune heure|{1} une heure|[X] heure|[X] heures" 

But in Polish, it's a bit more complex with 3 forms: Particular cases for "1" and numbers ending in 2, 3 and 4 but not with 12 and 13

0 godzin
1 godzina
2 godziny
3 godziny
4 godziny
5 godzin
6 godzin
7 godzin
8 godzin
9 godzin
10 godzin
11 godzin
12 godzin
13 godzin
14 godzin
15 godzin
...
21 godzin
22 godziny
23 godziny
24 godziny
25 godzin
...
100 godzin
101 godzin
102 godziny
103 godziny
104 godziny
105 godzin
...

Which corresponds to this rule, found in the CB file mentionned above:

nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : 2);

So the polish translation would be (with "one year" translating to "jedna godzina"):

'X_YEARS' => "jedna godzina|[X] godziny|[X] godzin" 

Combining the years, months, days, hours, minutes and seconds

There are 3 new named strings as well:

'CB_FIRST_COMMA_OF_YEARS_COMMA_MONTHS_AND_DAYS' => ", ",
'CB_LAST_AND_OF_YEARS_COMMA_MONTHS_AND_DAYS' => " and ",
'CB_ONLY_AND_OF_YEARS_AND_MONTHS' => " and " 
  • Thie first 2 are f is fir the case with 3 or more date/time periods, e.g: "1 hour, 2 minutes and 3 seconds"
  • The 3rd and last is for cases with 2 date/time periods, e.g. "4 months and 5 days"

Also note that for years, months and days, there are also calendar variants: E.g.:

'X_CALENDAR_YEARS' => "one calendar year|[X] calendar years" 

IMPORTANT: note the spaces before and after the " and ", and after the comma ", " for correct formatting.

Forms "X time ago", "in X time" and "X time"

Some languages have conjugation depending on the use of the time period. E.g. (serbian):

That's why there are 3 forms, identical in English, but can be different in other languages:

X_MONTHS
X_MONTHS_PAST
X_MONTHS_FUTURE

Actions #3

Updated by beat almost 4 years ago

  • Status changed from Assigned to Resolved
  • % Done changed from 0 to 100

Implemented in MR !1566

Actions #4

Updated by beat almost 4 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF