1HTML::FormHandler::TraiUtsFeorr:C:oIn1t8rNi(b3u)ted PerlHTDMoLc:u:mFeonrtmaHtainodnler::TraitFor::I18N(3)
2
3
4
6 HTML::FormHandler::TraitFor::I18N - localization
7
9 version 0.40068
10
11 language_handle, _build_language_handle
12
13 Holds a Locale::Maketext (or other duck_type class with a 'maketext'
14 method) language handle. The language handle is used to localize the
15 error messages in the field's 'add_error' method. It's also used in
16 various places in rendering to localize labels and button values, etc.
17
18 The builder for this attribute gets the Locale::Maketext language
19 handle from the environment variable $ENV{LANGUAGE_HANDLE}:
20
21 $ENV{LANGUAGE_HANDLE} = 'en_en';
22
23 ...or creates a default language handler using HTML::FormHandler::I18N.
24 (Note that earlier versions required an actual object reference in ENV,
25 which is a bad practice and no longer supported.) You can pass in an
26 existing Locale::MakeText subclass instance or create one in a builder.
27
28 In a form class:
29
30 sub _build_language_handle { MyApp::I18N::abc_de->new }
31
32 Passed into new or process:
33
34 my $lh = MyApp::I18N::abc_de->new;
35 my $form = MyApp::Form->new( language_handle => $lh );
36
37 If you do not set the language_handle, then Locale::Maketext and/or
38 I18N::LangTags may guess, with unexpected results.
39
40 You can use non-Locale::Maketext language handles, such as
41 Data::Localize. There's an example of building a Data::Localize
42 language handle in t/xt/locale_data_localize.t in the distribution.
43
44 If you don't want a particular error message to go through
45 localization, you can use 'push_errors' and 'push_form_errors' instead
46 of 'add_error' and 'add_form_errors'.
47
48 Example of getting the language handle from the Catalyst context (where
49 the Catalyst context is passed in with 'ctx'):
50
51 has '+language_handle' => ( builder => 'get_language_handle_from_ctx' );
52 sub get_language_handle_from_ctx {
53 my $self = shift;
54 return MyApp::I18N->get_handle(
55 @{ $self->ctx->languages } );
56 }
57
59 FormHandler Contributors - see HTML::FormHandler
60
62 This software is copyright (c) 2017 by Gerda Shank.
63
64 This is free software; you can redistribute it and/or modify it under
65 the same terms as the Perl 5 programming language system itself.
66
67
68
69perl v5.34.0 2022-01-2H1TML::FormHandler::TraitFor::I18N(3)