Skip to content

Commit

Permalink
[FEATURE] ReadableDate badges in backend: Don't use "1 days ago" but …
Browse files Browse the repository at this point in the history
…"1 day ago" now

Same for minutes and hours
  • Loading branch information
einpraegsam committed Aug 11, 2023
1 parent 97500ac commit 4d049ae
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
18 changes: 15 additions & 3 deletions Classes/ViewHelpers/Format/ReadableDateViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,31 @@ protected function renderNow(): string
protected function renderMinutes(DateInterval $date): string
{
$minutes = $date->i;
return (string)LocalizationUtility::translateByKey('readabledate.minutes', [$minutes]);
$key = 'readabledate.minute';
if ($minutes > 1) {
$key .= 's';
}
return (string)LocalizationUtility::translateByKey($key, [$minutes]);
}

protected function renderHours(DateInterval $date): string
{
$hours = $date->h;
return (string)LocalizationUtility::translateByKey('readabledate.hours', [$hours]);
$key = 'readabledate.hour';
if ($hours > 1) {
$key .= 's';
}
return (string)LocalizationUtility::translateByKey($key, [$hours]);
}

protected function renderDays(DateInterval $date): string
{
$days = $date->d;
return (string)LocalizationUtility::translateByKey('readabledate.days', [$days]);
$key = 'readabledate.day';
if ($days > 1) {
$key .= 's';
}
return (string)LocalizationUtility::translateByKey($key, [$days]);
}

protected function renderDate(DateTime $date): string
Expand Down
12 changes: 12 additions & 0 deletions Resources/Private/Language/de.locallang_db.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -653,14 +653,26 @@
<source>now</source>
<target state="translated">jetzt</target>
</trans-unit>
<trans-unit id="readabledate.minute">
<source>%s minute ago</source>
<target state="translated">vor %s Minute</target>
</trans-unit>
<trans-unit id="readabledate.minutes">
<source>%s minutes ago</source>
<target state="translated">vor %s Minuten</target>
</trans-unit>
<trans-unit id="readabledate.hour">
<source>%s hour ago</source>
<target state="translated">vor %s Stunde</target>
</trans-unit>
<trans-unit id="readabledate.hours">
<source>%s hours ago</source>
<target state="translated">vor %s Stunden</target>
</trans-unit>
<trans-unit id="readabledate.day">
<source>%s day ago</source>
<target state="translated">vor %s Tag</target>
</trans-unit>
<trans-unit id="readabledate.days">
<source>%s days ago</source>
<target state="translated">vor %s Tagen</target>
Expand Down
9 changes: 9 additions & 0 deletions Resources/Private/Language/locallang_db.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -496,12 +496,21 @@
<trans-unit id="readabledate.now">
<source>now</source>
</trans-unit>
<trans-unit id="readabledate.minute">
<source>%s minute ago</source>
</trans-unit>
<trans-unit id="readabledate.minutes">
<source>%s minutes ago</source>
</trans-unit>
<trans-unit id="readabledate.hour">
<source>%s hour ago</source>
</trans-unit>
<trans-unit id="readabledate.hours">
<source>%s hours ago</source>
</trans-unit>
<trans-unit id="readabledate.day">
<source>%s day ago</source>
</trans-unit>
<trans-unit id="readabledate.days">
<source>%s days ago</source>
</trans-unit>
Expand Down

0 comments on commit 4d049ae

Please sign in to comment.