1Locale::Maketext::ExtraUcste:r:PCloungtirni:b:uTtTe2dL(o3Pc)earlle:D:oMcaukmeetnetxatt:i:oEnxtract::Plugin::TT2(3)
2
3
4
6 Locale::Maketext::Extract::Plugin::TT2 - Template Toolkit format parser
7
9 version 1.00
10
12 $plugin = Locale::Maketext::Extract::Plugin::TT2->new(
13 $lexicon # A Locale::Maketext::Extract object
14 @file_types # Optionally specify a list of recognised file types
15 )
16
17 $plugin->extract($filename,$filecontents);
18
20 Extracts strings to localise from Template Toolkit templates.
21
23 tt2
24
26 Valid formats are:
27
28 [% |l(args) %]string[% END %]
29 [% 'string' | l(args) %]
30 [% l('string',args) %]
31 [% c.l('string') %]
32 Also all the above combinations with "c." prepended should work
33 correctly. This is the default syntax when using TT templates with
34 Mojolicious.
35
36 l and loc are interchangeable.
37
38 | and FILTER are interchangeable.
39
41 .tt
42 .tt2
43 .html
44 .tt.*
45 .tt2.*
46
48 Template
49
51 · BEWARE Using the "loc" form can give false positives if you use the
52 Perl parser plugin on TT files. If you want to use the "loc" form,
53 then you should specify the file types that you want to the Perl
54 plugin to parse, or enable the default file types, eg:
55
56 xgetext.pl -P perl .... # default file types
57 xgettext.pl -P perl=pl,pm ... # specified file types
58
59 · The string-to-be-localised must be a string, not a variable. We try
60 not to extract calls to your localise function which contain
61 variables eg:
62
63 l('string',arg) # extracted
64 l(var,arg) # not extracted
65
66 This doesn't work for block filters, so don't do that. Eg:
67
68 [% FILTER l %]
69 string [% var %] # BAD!
70 [% END %]
71
72 · Getting the right line number is difficult in TT. Often it'll be a
73 range of lines, or it may be thrown out by the use of PRE_CHOMP or
74 POST_CHOMP. It will always be within a few lines of the correct
75 location.
76
77 · If you have PRE/POST_CHOMP enabled by default in your templates,
78 then you should extract the strings using the same values. In
79 order to set them, you can use the following wrapper script:
80
81 #!/usr/bin/perl
82
83 use Locale::Maketext::Extract::Run qw(xgettext);
84 use Locale::Maketext::Extract::Plugin::TT2();
85
86 %Locale::Maketext::Extract::Plugin::TT2::PARSER_OPTIONS = (
87 PRE_CHOMP => 1, # or 2
88 POST_CHOMP => 1, # or 2
89
90 # Also START/END_TAG, ANYCASE, INTERPOLATE, V1DOLLAR, EVAL_PERL
91 );
92
93 xgettext(@ARGV);
94
96 Thanks to Andy Wardley for writing the Template::Directive subclass
97 which made this possible.
98
100 xgettext.pl
101 for extracting translatable strings from common template systems
102 and perl source files.
103
104 Locale::Maketext::Lexicon
105 Locale::Maketext::Extract::Plugin::Base
106 Locale::Maketext::Extract::Plugin::FormFu
107 Locale::Maketext::Extract::Plugin::Perl
108 Locale::Maketext::Extract::Plugin::YAML
109 Locale::Maketext::Extract::Plugin::Mason
110 Locale::Maketext::Extract::Plugin::TextTemplate
111 Locale::Maketext::Extract::Plugin::Generic
112 Template::Toolkit
113
115 Clinton Gormley <clint@traveljury.com>
116
117 Andy Wardley http://wardley.org
118
120 Copyright 2002-2013 by Audrey Tang <cpan@audreyt.org>.
121
122 This software is released under the MIT license cited below.
123
124 The "MIT" License
125 Permission is hereby granted, free of charge, to any person obtaining a
126 copy of this software and associated documentation files (the
127 "Software"), to deal in the Software without restriction, including
128 without limitation the rights to use, copy, modify, merge, publish,
129 distribute, sublicense, and/or sell copies of the Software, and to
130 permit persons to whom the Software is furnished to do so, subject to
131 the following conditions:
132
133 The above copyright notice and this permission notice shall be included
134 in all copies or substantial portions of the Software.
135
136 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
137 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
138 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
139 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
140 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
141 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
142 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
143
145 · Clinton Gormley <drtech@cpan.org>
146
147 · Audrey Tang <cpan@audreyt.org>
148
150 This software is Copyright (c) 2014 by Audrey Tang.
151
152 This is free software, licensed under:
153
154 The MIT (X11) License
155
156
157
158perl v5.30.1 2020L-o0c1a-l3e0::Maketext::Extract::Plugin::TT2(3)