[Catalyst] setting the locale
withDBIx::Class::InflateColumn::DateTime
Octavian Rasnita
orasnita at gmail.com
Fri Apr 24 10:51:33 GMT 2009
From: "Moritz Onken" <onken at houseofdesign.de>
>
> Am 24.04.2009 um 10:53 schrieb Octavian Rasnita:
>
>> Hi,
>>
>> (Sorry for asking on this list, but my messages are rejected from DBIC
>> mailing list.)
>>
>> Is it possible to set the locale for a certain date field if
>> DBIx::Class::InflateColumn::DateTime is used when using that date, and
>> not in the class definition?
>>
>> I don't think it is OK to hard code the locale for a certain column in
>> the class definition, because the data from that column might be
>> presented in different languages, for different locales.
>>
>> In the POD documentation of DBIx::Class::InflateColumn::DateTime I've
>> learned how to set the locale for the date columns, but only by setting
>> it in the class definition.
>>
>> I've tried to set it when I used it, like
>>
>> $class->date_field->month_name(locale => 'ro_RO')
>> or
>> $class->date_field->month_name({locale => 'ro_RO'})
>>
>> with no luck, of course.
>>
>> Thank you for any hints.
>
> IMHO this is something the view should handle. The model's output should
> stay the same regardless of which locale the user has.
>
> What view classes are you using? I usually write a TT macro which sets
> the locale and/or timezone to the user's preferences.
>
>
> moritz
I found that I can use
$class_name->date_field->set_locale('ro')->month_name
I found that the last version of the Catalyst DBIC::Schema helper adds
InflateColumn::DateTime component by default, and until now I was using a
raw date like
[% row.date %]
and it printed a date like 2009-04-24.
Now it prints it as 2009-04-24T00:00:00.
I wanted to correct this and this is how I became interested about also
localizing the dates.
Thanks.
Octavian
More information about the Catalyst
mailing list