1CGI::FormBuilder::MessaUgseesr(3C)ontributed Perl DocumeCnGtIa:t:iFoonrmBuilder::Messages(3)
2
3
4
6 CGI::FormBuilder::Messages - Localized message support for FormBuilder
7
9 use CGI::FormBuilder::Messages;
10
11 my $mesg = CGI::FormBuilder::Messages->new(
12 $file || \%hash || ':locale'
13 );
14
15 print $mesg->js_invalid_text;
16
18 This module handles localization for FormBuilder. It is invoked by
19 specifying the "messages" option to FormBuilder's "new()" method.
20 Currently included with FormBuilder are several different locales:
21
22 English (default) en_US
23 Danish da_DK
24 German/Deutsch de_DE
25 Spanish/Espanol es_ES
26 Japanese ja_JP
27 Norwegian/Norvegian no_NO
28 Turkish tr_TR
29
30 To enable automatic localization that will detect the client's locale
31 and use one of these included locales, simply turn on "auto" messages:
32
33 my $form = CGI::FormBuilder->new(messages => 'auto');
34
35 Or, to use a specific locale, specify it as ":locale"
36
37 # Force Danish messages
38 my $form = CGI::FormBuilder->new(messages => ':da_DK');
39
40 In addition to these included locales, you can completely customize
41 your own messages. Each message that FormBuilder outputs is given a
42 unique key. You can selectively override FormBuilder messages by
43 specifying a different message string for a given message key.
44
45 To do so, first create a file and give it a unique name. In this
46 example we will use a shortened locale as the suffix:
47
48 # messages.en
49 # FormBuilder messages for "en" locale
50 js_invalid_start %s error(s) were found in your form:\n
51 js_invalid_end Fix these fields and try again!
52 js_invalid_select - You must choose an option for the "%s" field\n
53
54 Then, specify this file to "new()".
55
56 my $form = CGI::FormBuilder->new(messages => 'messages.en');
57
58 Alternatively, you could specify this directly as a hashref:
59
60 my $form = CGI::FormBuilder->new(
61 messages => {
62 js_invalid_start => '%s error(s) were found in your form:\n',
63 js_invalid_end => 'Fix these fields and try again!',
64 js_invalid_select => '- Choose an option from the "%s" list\n',
65 }
66 );
67
68 Although in practice this is rarely useful, unless you just want to
69 tweak one or two things.
70
71 This system is easy, and there are many many messages that can be
72 customized. Here is a list of messages, along with their default
73 values:
74
75 form_invalid_input Invalid entry
76 form_invalid_checkbox Check one or more options
77 form_invalid_file Invalid filename
78 form_invalid_password Invalid entry
79 form_invalid_radio Choose an option
80 form_invalid_select Select an option from this list
81 form_invalid_textarea Please fill this in
82 form_invalid_default Invalid entry
83
84 form_invalid_text %s error(s) were encountered with your submission.
85 Please correct the fields %shighlighted%s below.
86
87 form_required_text Fields that are %shighlighted%s are required.
88
89 form_confirm_text Success! Your submission has been received %s.
90
91 form_select_default -select-
92 form_grow_default Additional %s
93 form_other_default Other:
94 form_reset_default Reset
95 form_submit_default Submit
96
97 js_noscript Please enable JavaScript or use a newer browser.
98 js_invalid_start %s error(s) were encountered with your submission:
99 js_invalid_end Please correct these fields and try again.
100
101 js_invalid_checkbox - Check one or more of the "%s" options
102 js_invalid_default - Invalid entry for the "%s" field
103 js_invalid_file - Invalid filename for the "%s" field
104 js_invalid_input - Invalid entry for the "%s" field
105 js_invalid_multiple - Select one or more options from the "%s" list
106 js_invalid_password - Invalid entry for the "%s" field
107 js_invalid_radio - Choose one of the "%s" options
108 js_invalid_select - Select an option from the "%s" list
109 js_invalid_textarea - Please fill in the "%s" field
110
111 mail_confirm_subject %s Submission Confirmation
112 mail_confirm_text Your submission has been received %s, and will be processed shortly.
113 mail_results_subject %s Submission Results
114
115 The "js_" tags are used in JavaScript alerts, whereas the "form_" tags
116 are used in HTML and templates managed by FormBuilder.
117
118 In some of the messages, you will notice a %s "printf" format. This is
119 because these messages will include certain details for you. For
120 example, the "js_invalid_start" tag will print the number of errors if
121 you include the %s format tag. Of course, this is optional, and you can
122 leave it out.
123
124 The best way to get an idea of how these work is to experiment a
125 little. It should become obvious really quickly.
126
128 Foreign language translations were contributed by the following people:
129
130 Danish translation (da_DK)
131 Jonas Smedegaard
132
133 German translation (de_DE)
134 Thilo Planz
135
136 Spanish translation (es_ES)
137 Florian Merges
138
139 French translation (fr_FR)
140 Laurent Dami
141
142 Japanese translation (ja_JP)
143 Toru Yamaguchi and Thilo Planz
144
145 Norwegian translation (no_NO)
146 Steinar Fremme
147
148 Turkish translation (tr_TR)
149 Recai OktaAaX
150
151 Thanks!
152
154 CGI::FormBuilder
155
157 $Id: Messages.pm 100 2007-03-02 18:13:13Z nwiger $
158
160 Copyright (c) 2000-2006 Nate Wiger <nate@wiger.org>. All Rights
161 Reserved.
162
163 This module is free software; you may copy this under the terms of the
164 GNU General Public License, or the Artistic License, copies of which
165 should have accompanied your Perl kit.
166
167
168
169perl v5.12.0 2007-03-02 CGI::FormBuilder::Messages(3)