Localized dates and times

Support for Traq 3.x
Post Reply
User avatar
Sitestorm
Newbie
Posts: 2
Joined: Tue Apr 08, 2014 11:41 pm

Localized dates and times

Post by Sitestorm » Wed Apr 09, 2014 1:21 am

I'm translating the component to Dutch, but cannot find a way to localize the dates and times. Is this possible?

User avatar
Jack
Advanced Member
Posts: 666
Joined: Fri Mar 27, 2009 7:37 pm
Location: Australia

Re: Localized dates and times

Post by Jack » Wed Apr 09, 2014 4:47 am

You can re-declare the "date" method in the language class and anywhere Traq uses the "ldate" function to localise the date and time, it will use your version of the "date" method.

User avatar
Sitestorm
Newbie
Posts: 2
Joined: Tue Apr 08, 2014 11:41 pm

Re: Localized dates and times

Post by Sitestorm » Wed Apr 09, 2014 5:47 pm

Excellent. Very elegant. For anyone finding this answer, these are my adjustments:
 
Add this method to your language file class (substitute your personal locale, this is for the Netherlands):

Code: Select all

public function date($format, $timestamp = null)
{
    setlocale(LC_ALL, 'nl_NL');
    $timestamp = strtotime($timestamp);
    return strftime($format, $timestamp);
}
And the format strings (add these in the AdminCP -> Settings):

Code: Select all

Date/Time:
%H:%M %d/%m/%Y

Date:
%d/%m/%Y

Timeline Day:
%A, %e %B %Y

Timeline Time:
%H:%M
Last edited by Sitestorm on Wed Apr 09, 2014 5:49 pm, edited 1 time in total.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests