1Locale::Maketext::LexicUosne(r3)Contributed Perl DocumenLtoactailoen::Maketext::Lexicon(3)
2
3
4

NAME

6       Locale::Maketext::Lexicon - Use other catalog formats in Maketext
7

VERSION

9       version 1.00
10

SYNOPSIS

12       As part of a localization class, automatically glob for available
13       lexicons:
14
15           package Hello::I18N;
16           use base 'Locale::Maketext';
17           use Locale::Maketext::Lexicon {
18               '*' => [Gettext => '/usr/local/share/locale/*/LC_MESSAGES/hello.mo'],
19               ### Uncomment to fallback when a key is missing from lexicons
20               # _auto   => 1,
21               ### Uncomment to decode lexicon entries into Unicode strings
22               # _decode => 1,
23               ### Uncomment to load and parse everything right away
24               # _preload => 1,
25               ### Uncomment to use %1 / %quant(%1) instead of [_1] / [quant, _1]
26               # _style  => 'gettext',
27           };
28
29       Explicitly specify languages, during compile- or run-time:
30
31           package Hello::I18N;
32           use base 'Locale::Maketext';
33           use Locale::Maketext::Lexicon {
34               de => [Gettext => 'hello_de.po'],
35               fr => [
36                   Gettext => 'hello_fr.po',
37                   Gettext => 'local/hello/fr.po',
38               ],
39           };
40           # ... incrementally add new lexicons
41           Locale::Maketext::Lexicon->import({
42               de => [Gettext => 'local/hello/de.po'],
43           })
44
45       Alternatively, as part of a localization subclass:
46
47           package Hello::I18N::de;
48           use base 'Hello::I18N';
49           use Locale::Maketext::Lexicon (Gettext => \*DATA);
50           __DATA__
51           # Some sample data
52           msgid ""
53           msgstr ""
54           "Project-Id-Version: Hello 1.3.22.1\n"
55           "MIME-Version: 1.0\n"
56           "Content-Type: text/plain; charset=iso8859-1\n"
57           "Content-Transfer-Encoding: 8bit\n"
58
59           #: Hello.pm:10
60           msgid "Hello, World!"
61           msgstr "Hallo, Welt!"
62
63           #: Hello.pm:11
64           msgid "You have %quant(%1,piece) of mail."
65           msgstr "Sie haben %quant(%1,Poststueck,Poststuecken)."
66

DESCRIPTION

68       This module provides lexicon-handling modules to read from other
69       localization formats, such as Gettext, Msgcat, and so on.
70
71       If you are unfamiliar with the concept of lexicon modules, please
72       consult Locale::Maketext and the "webl10n" HTML files in the "docs/"
73       directory of this module.
74
75       A command-line utility xgettext.pl is also installed with this module,
76       for extracting translatable strings from source files.
77
78   The "import" function
79       The "import()" function accepts two forms of arguments:
80
81       (format => source ... )
82           This form takes any number of argument pairs (usually one); source
83           may be a file name, a filehandle, or an array reference.
84
85           For each such pair, it pass the contents specified by the second
86           argument to Locale::Maketext::Lexicon::format->parse as a plain
87           list, and export its return value as the %Lexicon hash in the
88           calling package.
89
90           In the case that there are multiple such pairs, the lexicon defined
91           by latter ones overrides earlier ones.
92
93       { language => [ format, source ... ] ... }
94           This form accepts a hash reference.  It will export a %Lexicon into
95           the subclasses specified by each language, using the process
96           described above.  It is designed to alleviate the need to set up a
97           separate subclass for each localized language, and just use the
98           catalog files.
99
100           This module will convert the language arguments into lowercase, and
101           replace all "-" with "_", so "zh_TW" and "zh-tw" will both map to
102           the "zh_tw" subclass.
103
104           If language begins with "_", it is taken as an option that controls
105           how lexicons are parsed.  See "Options" for a list of available
106           options.
107
108           The "*" is a special language; it must be used in conjunction with
109           a filename that also contains "*"; all matched files with a valid
110           language code in the place of "*" will be automatically prepared as
111           a lexicon subclass.  If there is multiple "*" in the filename, the
112           last one is used as the language name.
113
114   Options
115       "_auto"
116           If set to a true value, missing lookups on lexicons are handled
117           silently, as if an "Auto" lexicon has been appended on all language
118           lexicons.
119
120       "_decode"
121           If set to a true value, source entries will be converted into
122           utf8-strings (available in Perl 5.6.1 or later).  This feature
123           needs the Encode or Encode::compat module.
124
125           Currently, only the "Gettext" backend supports this option.
126
127       "_encoding"
128           This option only has effect when "_decode" is set to true.  It
129           specifies an encoding to store lexicon entries, instead of
130           utf8-strings.
131
132           If "_encoding" is set to "locale", the encoding from the current
133           locale setting is used.
134
135       "_preload"
136           By default parsing is delayed until first use of the lexicon, set
137           this option to true value to parse it asap. Increment adding
138           lexicons forces parsing.
139
140   Subclassing format handlers
141       If you wish to override how sources specified in different data types
142       are handled, please use a subclass that overrides "lexicon_get_TYPE".
143
144       XXX: not documented well enough yet.  Patches welcome.
145

VERSION

147       This document describes version 0.91 of Locale::Maketext::Lexicon.
148

NOTES

150       When you attempt to localize an entry missing in the lexicon, Maketext
151       will throw an exception by default.  To inhibit this behaviour,
152       override the "_AUTO" key in your language subclasses, for example:
153
154           $Hello::I18N::en::Lexicon{_AUTO} = 1; # autocreate missing keys
155
156       If you want to implement a new "Lexicon::*" backend module, please note
157       that "parse()" takes an array containing the source strings from the
158       specified filehandle or filename, which are not "chomp"ed.  Although if
159       the source is an array reference, its elements will probably not
160       contain any newline characters anyway.
161
162       The "parse()" function should return a hash reference, which will be
163       assigned to the typeglob (*Lexicon) of the language module.  All it
164       amounts to is that if the returned reference points to a tied hash, the
165       %Lexicon will be aliased to the same tied hash if it was not
166       initialized previously.
167

ACKNOWLEDGMENTS

169       Thanks to Jesse Vincent for suggesting this module to be written.
170
171       Thanks also to Sean M. Burke for coming up with Locale::Maketext in the
172       first place, and encouraging me to experiment with alternative Lexicon
173       syntaxes.
174
175       Thanks also to Yi Ma Mao for providing the MO file parsing subroutine,
176       as well as inspiring me to implement file globbing and transcoding
177       support.
178
179       See the AUTHORS file in the distribution for a list of people who have
180       sent helpful patches, ideas or comments.
181

SEE ALSO

183       xgettext.pl for extracting translatable strings from common template
184       systems and perl source files.
185
186       Locale::Maketext, Locale::Maketext::Lexicon::Auto,
187       Locale::Maketext::Lexicon::Gettext, Locale::Maketext::Lexicon::Msgcat,
188       Locale::Maketext::Lexicon::Tie
189

AUTHORS

191       Audrey Tang <cpan@audreyt.org>
192
194       Copyright 2002-2013 by Audrey Tang <cpan@audreyt.org>.
195
196       This software is released under the MIT license cited below.
197
198   The "MIT" License
199       Permission is hereby granted, free of charge, to any person obtaining a
200       copy of this software and associated documentation files (the
201       "Software"), to deal in the Software without restriction, including
202       without limitation the rights to use, copy, modify, merge, publish,
203       distribute, sublicense, and/or sell copies of the Software, and to
204       permit persons to whom the Software is furnished to do so, subject to
205       the following conditions:
206
207       The above copyright notice and this permission notice shall be included
208       in all copies or substantial portions of the Software.
209
210       THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
211       OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
212       MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
213       IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
214       CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
215       TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
216       SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
217

AUTHORS

219       ·   Clinton Gormley <drtech@cpan.org>
220
221       ·   Audrey Tang <cpan@audreyt.org>
222
224       This software is Copyright (c) 2014 by Audrey Tang.
225
226       This is free software, licensed under:
227
228         The MIT (X11) License
229
230
231
232perl v5.32.0                      2020-07-28      Locale::Maketext::Lexicon(3)
Impressum