1Locale::Maketext::ExtraUcste(r3)Contributed Perl DocumenLtoactailoen::Maketext::Extract(3)
2
3
4
6 Locale::Maketext::Extract - Extract translatable strings from source
7
9 my $Ext = Locale::Maketext::Extract->new;
10 $Ext->read_po('messages.po');
11 $Ext->extract_file($_) for <*.pl>;
12
13 # Set $entries_are_in_gettext_format if the .pl files above use
14 # loc('%1') instead of loc('[_1]')
15 $Ext->compile($entries_are_in_gettext_format);
16
17 $Ext->write_po('messages.po');
18
20 This module can extract translatable strings from files, and write them
21 back to PO files. It can also parse existing PO files and merge their
22 contents with newly extracted strings.
23
24 A command-line utility, xgettext.pl, is installed with this module as
25 well.
26
27 Following formats of input files are supported:
28
29 Perl source files
30 Valid localization function names are: "translate", "maketext",
31 "gettext", "loc", "x", "_" and "__".
32
33 HTML::Mason
34 Strings inside "<&⎪/l>...</&>" and "<&⎪/loc>...</&>" are extracted.
35
36 Template Toolkit
37 Strings inside "[%⎪l%]...[%END%]" or "[%⎪loc%]...[%END%]" are
38 extracted.
39
40 Text::Template
41 Sentences between "STARTxxx" and "ENDxxx" are extracted individu‐
42 ally.
43
44 HTML::FormFu
45 HTML::FormFu uses a config-file to generate forms, with built in
46 support for localizing errors, labels etc.
47
48 We extract the text after "_loc: ":
49 content_loc: this is the string
50
51 Generic Template
52 Strings inside {{...}} are extracted.
53
55 Constructor
56
57 new
58
59 Accessors
60
61 header, set_header
62 lexicon, set_lexicon, msgstr, set_msgstr
63 entries, set_entries, entry, add_entry, del_entry
64 compiled_entries, set_compiled_entries, compiled_entry,
65 add_compiled_entry, del_compiled_entry
66 clear
67
68 PO File manipulation
69
70 method read_po ($file)
71
72 method write_po ($file, $add_format_marker?)
73
74 Extraction
75
76 extract
77 extract_file
78
79 Compilation
80
81 compile($entries_are_in_gettext_style?)
82
83 Merges the "entries" into "compiled_entries".
84
85 If $entries_are_in_gettext_style is true, the previously extracted
86 entries are assumed to be in the Gettext style (e.g. %1).
87
88 Otherwise they are assumed to be in Maketext style (e.g. "[_1]") and
89 are converted into Gettext style before merging into "com‐
90 piled_entries".
91
92 The "entries" are not cleared after each compilation; use
93 "-"set_entries()> to clear them if you need to extract from sources
94 with varying styles.
95
96 normalize_space
97
98 Lexicon accessors
99
100 msgids, has_msgid,
101 msgstr, set_msgstr
102 msg_positions, msg_variables, msg_format, msg_out
103
104 Internal utilities
105
106 _default_header
107 _maketext_to_gettext
108 _escape
109 _format
110
112 Thanks to Jesse Vincent for contributing to an early version of this
113 module.
114
115 Also to Alain Barbet, who effectively re-wrote the source parser with a
116 flex-like algorithm.
117
119 xgettext.pl, Locale::Maketext, Locale::Maketext::Lexicon
120
122 Audrey Tang <cpan@audreyt.org>
123
125 Copyright 2003-2008 by Audrey Tang <cpan@audreyt.org>.
126
127 This software is released under the MIT license cited below.
128
129 The "MIT" License
130
131 Permission is hereby granted, free of charge, to any person obtaining a
132 copy of this software and associated documentation files (the "Soft‐
133 ware"), to deal in the Software without restriction, including without
134 limitation the rights to use, copy, modify, merge, publish, distribute,
135 sublicense, and/or sell copies of the Software, and to permit persons
136 to whom the Software is furnished to do so, subject to the following
137 conditions:
138
139 The above copyright notice and this permission notice shall be included
140 in all copies or substantial portions of the Software.
141
142 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
143 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MER‐
144 CHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
145 NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
146 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
147 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFT‐
148 WARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
149
150
151
152perl v5.8.8 2008-01-07 Locale::Maketext::Extract(3)