[html-formfu] Setting the current language

Carl Franks fireartist at gmail.com
Thu Oct 15 07:46:25 GMT 2009


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



More information about the HTML-FormFu mailing list