Hi
I have a problem with translating date display, from English into Danish. The month is not translated in the Danish date display. Does anyone know how it can be done.
In the language file there is a translation of months with 'date: month: 01' => 'January% s', etc., but the translation is not used in the general date display.
English
Danish
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by Raül Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
Hi gillie in the language file you will see a line something like this
'friendlytime:date_format' => 'j F Y @ g:ia',
I don't know how to translate the months to other languages but you could choose a different format
here is the table of php time date settings http://php.net/manual/en/function.date.php
Thank you, Susan.
I'm afraid it's not that simple. F in the dateformat is what I want, a full textual representation of a month. But in php a danish substitute for F doesn't exist.
I use j. F Y | H:i which display 2. July 2010 | 11:00. In danish the months are in lower case and spelled different so it should be - 2. juli 2010 | 11.00.
I could translate the month and put them in the language file but how would I display them? So in a way date display is partly hardcoded in elgg. The substring F is not in any language files but one.
If you look at for example "Blogs" you'll see a monthly archive in left side menu with translation of months. That's what I would like. Those months are translated in the main language file and displayed correctly.
I was hoping that a skilled coder could give me some guidance.
@Gilllie:) actually I have the same problem - I would be very happy to receive guidance on how to deal with the date time translation correctly, instead of just trying to work round it. My network is in Hebrew which means a completely different alphabet and language direction
Did you try to read new view (views/default/output/friendlytime.php ) and read code in order to detect, who and where write date in the title of link?
OK, catch it. Never trust Eglish-speaking people to write good 18n'able code. Extractions from output/friendlytime.php
but PHP:date - Manual in pure English clearly states
I.e
1. if setlocale() already set somewhere (I'm too lazy to verify code, you see good or bad result after test), you have to
$timestamp = htmlentities(strftime(elgg_echo('friendlytime:date_format'), $vars['time']));
2. if setlocale not defined (1-st test return unwanted text) you have to add
before $timestamp definition in addition to previous changes
PS - "The Right Way" (tm) will be perform all these actions in own custom theme, where you can safe redefine default views
PPS - even The More Right Way will be to fill bug-report to Trac also
You can override the view that Alexander pointed out and use something like this:
$oldLocale = setlocale(LC_TIME, 'fr_FR.UTF-8');
$timestamp = strftime("%a %d %b %Y", $vars['time']);
setlocale(LC_TIME, $oldLocale);
You need to make sure that the locale you use is installed on your server.
Edit: As Alexander so graciously points out below, I'm wrong about the return value of setlocale.
Ah, I see Alexander already beat me to it.
Thank you all. I will try to figure it out :)
@all
seems we're all tripping over over own feet to get this code right..
I've put up a few examples here -->
http://malagajack.com/SetDates1.php
just playing around with the code ;-)
2Cash:
WTF???
RTFM from setlocale:
- Previous
- 1
- 2
- 3
- 4
- Next
You must log in to post replies.