mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
ENHANCEMENT Making Date->Ago() translatable
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@68761 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
345ec4e885
commit
76f4af842e
@ -95,10 +95,27 @@ class Date extends DBField {
|
||||
*/
|
||||
function Ago() {
|
||||
if($this->value) {
|
||||
if(time() < strtotime($this->value)) $agoWord = _t("Date.AWAY", " away");
|
||||
else $agoWord = _t("Date.AGO", " ago");
|
||||
|
||||
return $this->TimeDiff() . ' ' . $agoWord;
|
||||
if(time() > strtotime($this->value)) {
|
||||
return sprintf(
|
||||
_t(
|
||||
'Date.TIMEDIFFAGO',
|
||||
"%s ago",
|
||||
PR_MEDIUM,
|
||||
'Natural language time difference, e.g. 2 hours ago'
|
||||
),
|
||||
$this->TimeDiff()
|
||||
);
|
||||
} else {
|
||||
return sprintf(
|
||||
_t(
|
||||
'Date.TIMEDIFFAWAY',
|
||||
"%s away",
|
||||
PR_MEDIUM,
|
||||
'Natural language time difference, e.g. 2 hours away'
|
||||
),
|
||||
$this->TimeDiff()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,8 +126,6 @@ $lang['en_US']['DataObject']['SINGULARNAME'] = array(
|
||||
50,
|
||||
'Singular name of the object, used in dropdowns and to generally identify a single object in the interface'
|
||||
);
|
||||
$lang['en_US']['Date']['AGO'] = ' ago';
|
||||
$lang['en_US']['Date']['AWAY'] = ' away';
|
||||
$lang['en_US']['Date']['DAY'] = ' day';
|
||||
$lang['en_US']['Date']['DAYS'] = ' days';
|
||||
$lang['en_US']['Date']['HOUR'] = ' hour';
|
||||
@ -138,6 +136,16 @@ $lang['en_US']['Date']['MONTH'] = ' month';
|
||||
$lang['en_US']['Date']['MONTHS'] = ' months';
|
||||
$lang['en_US']['Date']['SEC'] = ' sec';
|
||||
$lang['en_US']['Date']['SECS'] = ' secs';
|
||||
$lang['en_US']['Date']['TIMEDIFFAGO'] = array(
|
||||
'%s ago',
|
||||
PR_MEDIUM,
|
||||
'Natural language time difference, e.g. 2 hours ago'
|
||||
);
|
||||
$lang['en_US']['Date']['TIMEDIFFAWAY'] = array(
|
||||
'%s away',
|
||||
PR_MEDIUM,
|
||||
'Natural language time difference, e.g. 2 hours away'
|
||||
);
|
||||
$lang['en_US']['Date']['YEAR'] = ' year';
|
||||
$lang['en_US']['Date']['YEARS'] = ' years';
|
||||
$lang['en_US']['DateField']['NOTSET'] = 'not set';
|
||||
|
Loading…
Reference in New Issue
Block a user