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 Russian ru_RU
30
31 To enable automatic localization that will detect the client's locale
32 and use one of these included locales, simply turn on "auto" messages:
33
34 my $form = CGI::FormBuilder->new(messages => 'auto');
35
36 Or, to use a specific locale, specify it as ":locale"
37
38 # Force Danish messages
39 my $form = CGI::FormBuilder->new(messages => ':da_DK');
40
41 In addition to these included locales, you can completely customize
42 your own messages. Each message that FormBuilder outputs is given a
43 unique key. You can selectively override FormBuilder messages by
44 specifying a different message string for a given message key.
45
46 To do so, first create a file and give it a unique name. In this
47 example we will use a shortened locale as the suffix:
48
49 # messages.en
50 # FormBuilder messages for "en" locale
51 js_invalid_start %s error(s) were found in your form:\n
52 js_invalid_end Fix these fields and try again!
53 js_invalid_select - You must choose an option for the "%s" field\n
54
55 Then, specify this file to "new()".
56
57 my $form = CGI::FormBuilder->new(messages => 'messages.en');
58
59 Alternatively, you could specify this directly as a hashref:
60
61 my $form = CGI::FormBuilder->new(
62 messages => {
63 js_invalid_start => '%s error(s) were found in your form:\n',
64 js_invalid_end => 'Fix these fields and try again!',
65 js_invalid_select => '- Choose an option from the "%s" list\n',
66 }
67 );
68
69 Although in practice this is rarely useful, unless you just want to
70 tweak one or two things.
71
72 This system is easy, and there are many many messages that can be
73 customized. Here is a list of messages, along with their default
74 values:
75
76 form_invalid_input Invalid entry
77 form_invalid_checkbox Check one or more options
78 form_invalid_file Invalid filename
79 form_invalid_password Invalid entry
80 form_invalid_radio Choose an option
81 form_invalid_select Select an option from this list
82 form_invalid_textarea Please fill this in
83 form_invalid_default Invalid entry
84
85 form_invalid_text %s error(s) were encountered with your submission.
86 Please correct the fields %shighlighted%s below.
87
88 form_required_text Fields that are %shighlighted%s are required.
89
90 form_confirm_text Success! Your submission has been received %s.
91
92 form_select_default -select-
93 form_grow_default Additional %s
94 form_other_default Other:
95 form_reset_default Reset
96 form_submit_default Submit
97
98 js_noscript Please enable JavaScript or use a newer browser.
99 js_invalid_start %s error(s) were encountered with your submission:
100 js_invalid_end Please correct these fields and try again.
101
102 js_invalid_checkbox - Check one or more of the "%s" options
103 js_invalid_default - Invalid entry for the "%s" field
104 js_invalid_file - Invalid filename for the "%s" field
105 js_invalid_input - Invalid entry for the "%s" field
106 js_invalid_multiple - Select one or more options from the "%s" list
107 js_invalid_password - Invalid entry for the "%s" field
108 js_invalid_radio - Choose one of the "%s" options
109 js_invalid_select - Select an option from the "%s" list
110 js_invalid_textarea - Please fill in the "%s" field
111
112 mail_confirm_subject %s Submission Confirmation
113 mail_confirm_text Your submission has been received %s, and will be processed shortly.
114 mail_results_subject %s Submission Results
115
116 The "js_" tags are used in JavaScript alerts, whereas the "form_" tags
117 are used in HTML and templates managed by FormBuilder.
118
119 In some of the messages, you will notice a %s "printf" format. This is
120 because these messages will include certain details for you. For
121 example, the "js_invalid_start" tag will print the number of errors if
122 you include the %s format tag. Of course, this is optional, and you can
123 leave it out.
124
125 The best way to get an idea of how these work is to experiment a
126 little. It should become obvious really quickly.
127
129 Foreign language translations were contributed by the following people:
130
131 Danish translation (da_DK)
132 Jonas Smedegaard
133
134 German translation (de_DE)
135 Thilo Planz
136
137 Spanish translation (es_ES)
138 Florian Merges
139
140 French translation (fr_FR)
141 Laurent Dami
142
143 Japanese translation (ja_JP)
144 Toru Yamaguchi and Thilo Planz
145
146 Norwegian translation (no_NO)
147 Steinar Fremme
148
149 Turkish translation (tr_TR)
150 Recai Oktaş
151
152 Thanks!
153
155 CGI::FormBuilder
156
158 $Id: Messages.pm 100 2007-03-02 18:13:13Z nwiger $
159
161 Copyright (c) Nate Wiger <http://nateware.com>. All Rights 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
168 Hey! The above document had some coding errors, which are explained
169 below:
170
171 Around line 292:
172 Non-ASCII character seen before =encoding in 'Oktaş'. Assuming
173 UTF-8
174
175
176
177perl v5.34.0 2021-07-22 CGI::FormBuilder::Messages(3)