Dates en locale: my months are displayed in English, should be in French

26 views
Skip to first unread message

Dam74

unread,
Jun 23, 2010, 5:27:58 AM6/23/10
to play-framework
Hi,


How (and where) should I deal with Locales so that the dates I display
in my pages have their months written in French ? (or in German for
german users, etc...)

Evenement créé le ${event.dateCreation.format('dd MMMM yyyy - HH:mm')}

Thanks,

Dam74

Erwan Loisant

unread,
Jun 23, 2010, 5:52:46 AM6/23/10
to play-fr...@googlegroups.com
Hi,

In a multilingual site you should just leave it that way, it will use
the current language. By default it looks at the browser's accept
language.

In a monolingual site you can pass the language as parameter, e.g.
${event.dateCreation.format('dd MMMM yyyy - HH:mm', 'fr')}

> --
> You received this message because you are subscribed to the Google Groups "play-framework" group.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.
>
>

--
Erwan Loisant

Dam74

unread,
Jun 26, 2010, 6:09:24 PM6/26/10
to play-framework
OK thanks...
I'm used to work in English, so maybe effectively my browser is set as
English,
so that would explain... I ll try to change my settings to test that.
Thanks a lot.

Julien Richard-Foy

unread,
Jun 27, 2010, 4:53:39 AM6/27/10
to play-framework
BTW, what do you think about adding an additionnal TimeZone parameter
to the format operation?

Guillaume Bort

unread,
Jun 27, 2010, 5:54:15 AM6/27/10
to play-fr...@googlegroups.com
Yes it would be useful.

--
Guillaume Bort, http://guillaume.bort.fr

For anything work-related, use g...@zenexity.fr; for everything else,
write guillau...@gmail.com

Julien Richard-Foy

unread,
Jun 27, 2010, 10:31:52 AM6/27/10
to play-framework
So here is a little patch (on 1.1 branch):

--- JavaExtensions.java.orig 2010-06-27 16:10:57.566844511 +0200
+++ JavaExtensions.java 2010-06-27 16:22:44.974851251 +0200
@@ -20,6 +20,7 @@
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
+import java.util.TimeZone;

import org.apache.commons.lang.StringEscapeUtils;

@@ -168,6 +169,12 @@
return new SimpleDateFormat(pattern, new
Locale(lang)).format(date);
}

+ public static String format(Date date, String pattern, String
lang, TimeZone tz) {
+ SimpleDateFormat dateFormat = new SimpleDateFormat(pattern,
new Locale(lang));
+ dateFormat.setTimeZone(tz);
+ return dateFormat.format(date);
+ }
+
public static Integer page(Number number, Integer pageSize) {
return number.intValue() / pageSize + (number.intValue() %
pageSize > 0 ? 1 : 0);
}

Hope this helps…

Julien
> Guillaume Bort,http://guillaume.bort.fr
>
> For anything work-related, use g...@zenexity.fr; for everything else,
> write guillaume.b...@gmail.com

Guillaume Bort

unread,
Jun 27, 2010, 6:14:01 PM6/27/10
to play-fr...@googlegroups.com
Thank you. But can you attach it to a bug report? It is easier to track.

On 27 juin 2010, at 16:31, Julien Richard-Foy <juli...@gmail.com>
wrote:

>>> fram...@googlegroups.com.


>>> To unsubscribe from this group, send email to play-framewor...@googlegroups.com
>>> .
>>> For more options, visit this group athttp://groups.google.com/
>>> group/play-framework?hl=en.
>>

>> --
>> Guillaume Bort,http://guillaume.bort.fr
>>
>> For anything work-related, use g...@zenexity.fr; for everything else,
>> write guillaume.b...@gmail.com
>

Dam74

unread,
Jul 20, 2010, 2:58:14 AM7/20/10
to play-framework
Erwan, sorry but the solution you proposed did not work:
"By default it looks at the browser's accept language."

Even if I move my browser's default language to "French" and remove
all the others, the month of the date is still in English.
Another precision is that when I deploy it to Stax servers, the time
is 2h less.

So I guess that my solution might have to do something with my
server...
Is there any config I need to modify in the "application.conf" file?

Thanks for your help

Dam74

On Jun 28, 12:14 am, Guillaume Bort <guillaume.b...@gmail.com> wrote:
> Thank you. But can you attach it to a bug report? It is easier to track.
>
> On 27 juin 2010, at 16:31, Julien Richard-Foy <julien...@gmail.com>  

Guillaume Bort

unread,
Jul 20, 2010, 4:49:21 AM7/20/10
to play-fr...@googlegroups.com
Try to set:

application.lang=fr

--
Guillaume Bort, http://guillaume.bort.fr

For anything work-related, use g...@zenexity.fr; for everything else,

write guillau...@gmail.com

Dam74

unread,
Jul 27, 2010, 11:11:04 AM7/27/10
to play-framework
Does not work either. So what I've done for the moment is that I've
modified
my date formater in order to display the month in numbers and not its
name...
Thanks
Reply all
Reply to author
Forward
0 new messages