1Locale::Maketext::ExtraUcste:r:PCloungtirni:b:uBtaeLsdoec(Pa3el)rel::DMoackuemteenxtta:t:iEoxntract::Plugin::Base(3)
2
3
4
6 Locale::Maketext::Extract::Plugin::Base - Base module for format parser
7 plugins
8
10 package My::Parser::Plugin;
11 use base qw(Locale::Maketext::Extract::Plugin::Base);
12
13 sub file_types {
14 return [qw( ext ext2 )]
15 }
16
17 sub extract {
18 my $self = shift;
19 my $filename = shift;
20 local $_ = shift;
21
22 my $line = 1;
23
24 while (my $found = $self->routine_to_extract_strings) {
25 $self->add_entry($str,[$filename,$line,$vars])
26 }
27
28 return;
29 }
30
32 All format parser plugins in Locale::Maketext::Extract inherit from
33 Locale::Maketext::Extract::Plugin::Base.
34
35 If you want to write your own custom parser plugin, you will need to
36 inherit from this module, and provide "file_types()" and "extract()"
37 methods, as shown above.
38
40 new()
41 $plugin = My::Parser->new(
42 @file_types # Optionally specify a list of recognised file types
43 )
44
45 add_entry()
46 $plugin->add_entry($str,$line,$vars)
47
48 "entries()"
49 $entries = $plugin->entries;
50
51 "clear()"
52 $plugin->clear
53
54 Clears all stored entries.
55
56 file_types()
57 @default_file_types = $plugin->file_types
58
59 Returns a list of recognised file types that your module knows how
60 to parse.
61
62 Each file type can be one of:
63
64 · A plain string
65
66 'pl' => base filename is matched against qr/\.pl$/
67 '*' => all files are accepted
68
69 · A regex
70
71 qr/\.tt2?\./ => base filename is matched against this regex
72
73 · A codref
74
75 sub {} => this codref is called as $coderef->($base_filename,$path_to_file)
76 It should return true or false
77
78 extract()
79 $plugin->extract($filecontents);
80
81 extract() is the method that will be called to process the contents
82 of the current file.
83
84 When it finds a string that should be extracted, it should call
85
86 $self->add_entry($string,$line,$vars])
87
88 where $vars refers to any arguments that are being passed to the
89 localise function. For instance:
90
91 l("You found [quant,_1,file,files]",files_found)
92
93 string: "You found [quant,_1,file,files]"
94 vars : (files_found)
95
96 IMPORTANT: a single plugin instance is used for all files, so if
97 you plan on storing state information in the $plugin object, this
98 should be cleared out at the beginning of "extract()"
99
100 known_file_type()
101 if ($plugin->known_file_type($filename_with_path)) {
102 ....
103 }
104
105 Determines whether the current file should be handled by this
106 parser, based either on the list of file_types specified when this
107 object was created, or the default file_types specified in the
108 module.
109
111 xgettext.pl
112 for extracting translatable strings from common template systems
113 and perl source files.
114
115 Locale::Maketext::Lexicon
116 Locale::Maketext::Extract::Plugin::Perl
117 Locale::Maketext::Extract::Plugin::PPI
118 Locale::Maketext::Extract::Plugin::TT2
119 Locale::Maketext::Extract::Plugin::YAML
120 Locale::Maketext::Extract::Plugin::FormFu
121 Locale::Maketext::Extract::Plugin::Mason
122 Locale::Maketext::Extract::Plugin::TextTemplate
123 Locale::Maketext::Extract::Plugin::Generic
124
126 Clinton Gormley [DRTECH] <clinton@traveljury.com>
127
129 Copyright 2002-2008 by Audrey Tang <cpan@audreyt.org>.
130
131 This software is released under the MIT license cited below.
132
133 The "MIT" License
134 Permission is hereby granted, free of charge, to any person obtaining a
135 copy of this software and associated documentation files (the
136 "Software"), to deal in the Software without restriction, including
137 without limitation the rights to use, copy, modify, merge, publish,
138 distribute, sublicense, and/or sell copies of the Software, and to
139 permit persons to whom the Software is furnished to do so, subject to
140 the following conditions:
141
142 The above copyright notice and this permission notice shall be included
143 in all copies or substantial portions of the Software.
144
145 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
146 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
147 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
148 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
149 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
150 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
151 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
152
153
154
155perl v5.12.2 201L0o-c0a8l-e1:0:Maketext::Extract::Plugin::Base(3)