[html-formfu] Setting the current language

Octavian Râşniţă orasnita at gmail.com
Thu Oct 15 11:32:07 GMT 2009


Hi,

Maybe it helps the others...

In order to make HTML::FormFu work well with Catalyst::Plugin::I18N::DBI, I 
needed to use the following settings:

'Controller::HTML::FormFu' => {
languages_from_context => 1,
localize_from_context => 1,
constructor => {
localize_class => 'Catalyst::Plugin::I18N::DBI',
},
},

languages_from_context was needed to translate the names of months from a 
Date and DateTime element.
localize_from_context  was needed to translate the other localized strings.

Octavian

From: "Carl Franks" <fireartist at gmail.com>


2009/10/14 Octavian Râşniţă <orasnita at gmail.com>:
> Hi,
>
> I have seen that if I add in a form configuration file (Config::General
> type):
>
> languages fr
>
> then French becomes the current language for localising the error 
> messages.
> But I don't know how to set that language dynamicly - from the program.
>
> I have tried:
>
> my $form = $c->stash->{form};
> $form->languages(['fr']);
>
> I have also tried to add $form->process; but nothing happends. The default
> language still remains English.

Hi,

If you set this in your config, it should automatically pick up
Catalyst's current setting.

'Controller::HTML::FormFu':
  languages_from_context: 1

Looking at the FormFu code, the only reason I can think of why your
code wouldn't work, it that $form->process() has already been called,
and something during process() triggered $form->localize() which has
set the default localize object - which is using the default ['en']
setting.
If you don't want to use the above config setting, you should be able
to set this theory by doing this after setting languages() manually:
    delete $form->{localize_data};
    delete $form->{has_default_localize_object};
If this solves it, we should probably make $form->languages() do
something similar, so it works as expected.

Cheers,
Carl

_______________________________________________
HTML-FormFu mailing list
HTML-FormFu at lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu 




More information about the HTML-FormFu mailing list