Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2008-03-17 12:35:46
- alex9142
- Member
- Registered: 2008-03-17
- Posts: 45
how to hack the function since($stamp)
function since($stamp) { $diff = (time() – $stamp); if ($diff <= 3600) { $mins = round($diff / 60); $since = ($mins <= 1) ? ($mins==1) ? ’1 ‘.gTxt(‘minute’) : gTxt(‘a_few_seconds’) : “$mins “.gTxt(‘minutes’); } else if (($diff <= 86400) && ($diff > 3600)) { $hours = round($diff / 3600); $since = ($hours <= 1) ? ’1 ‘.gTxt(‘hour’) : “$hours “.gTxt(‘hours’); } else if ($diff >= 86400) { $days = round($diff / 86400); $since = ($days <= 1) ? “1 “.gTxt(‘day’) : “$days “.gTxt(‘days’); } return $since.’ ‘.gTxt(‘ago’); // sorry, this needs to be hacked until a truly multilingual version is done }
================
the code above is in /textpattern/lib/txplib_misc.php
My language is portuguese, and the correct way to show the time is:
há 2 dias
But the system shows:
2 dias há (translanting: 2 days ago)
How can I change this?
Thank you.
Offline
#2 2008-03-17 20:21:45
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: how to hack the function since($stamp)
function since($stamp)
{
$diff = (time() - $stamp);
if ($diff <= 3600) {
$mins = round($diff / 60);
$since = ($mins <= 1)
? ($mins==1)
? '1 '.gTxt('minute')
: gTxt('a_few_seconds')
: "$mins ".gTxt('minutes');
} else if (($diff <= 86400) && ($diff > 3600)) {
$hours = round($diff / 3600);
$since = ($hours <= 1) ? '1 '.gTxt('hour') : "$hours ".gTxt('hours');
} else if ($diff >= 86400) {
$days = round($diff / 86400);
$since = ($days <= 1) ? "1 ".gTxt('day') : "$days ".gTxt('days');
}
// return $since.' '.gTxt('ago'); // sorry, this needs to be hacked until a truly multilingual version is done
return gTxt('ago').' '.$since; // this is the hack
}
Offline
#3 2008-03-17 21:51:04
- alex9142
- Member
- Registered: 2008-03-17
- Posts: 45
Re: how to hack the function since($stamp)
finally…
a big THANk You, Els !
Offline