| 1 |
|
| 2 |
################################################################################### |
| 3 |
# |
| 4 |
# Embperl - Copyright (c) 1997-2008 Gerald Richter / ecos gmbh www.ecos.de |
| 5 |
# Embperl - Copyright (c) 2008-2014 Gerald Richter |
| 6 |
# |
| 7 |
# You may distribute under the terms of either the GNU General Public |
| 8 |
# License or the Artistic License, as specified in the Perl README file. |
| 9 |
# |
| 10 |
# THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR |
| 11 |
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
| 12 |
# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
| 13 |
# |
| 14 |
# $Id: MsgIdExtract.pm 1578075 2014-03-16 14:01:14Z richter $ |
| 15 |
# |
| 16 |
################################################################################### |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
package Embperl::Syntax::MsgIdExtract ; |
| 21 |
|
| 22 |
use Embperl::Syntax (':types') ; |
| 23 |
|
| 24 |
use strict ; |
| 25 |
use vars qw{@ISA %Blocks %BlocksOutput %BlocksOutputLink} ; |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
@ISA = qw(Embperl::Syntax) ; |
| 30 |
|
| 31 |
|
| 32 |
################################################################################### |
| 33 |
# |
| 34 |
# Methods |
| 35 |
# |
| 36 |
################################################################################### |
| 37 |
|
| 38 |
# --------------------------------------------------------------------------------- |
| 39 |
# |
| 40 |
# Create new Syntax Object |
| 41 |
# |
| 42 |
# --------------------------------------------------------------------------------- |
| 43 |
|
| 44 |
sub new |
| 45 |
|
| 46 |
{ |
| 47 |
my $self = shift ; |
| 48 |
|
| 49 |
$self = Embperl::Syntax::new ($self) ; |
| 50 |
|
| 51 |
if (!$self -> {-epbMsgIdExtract}) |
| 52 |
{ |
| 53 |
$self -> {-epbMsgIdExtract} = $self -> CloneHash (\%Blocks) ; |
| 54 |
|
| 55 |
$self -> AddToRoot ($self -> {-epbMsgIdExtract}) ; |
| 56 |
} |
| 57 |
|
| 58 |
return $self ; |
| 59 |
} |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
%Blocks = ( |
| 64 |
'-lsearch' => 1, |
| 65 |
'Embperl command escape' => { |
| 66 |
'text' => '[[', |
| 67 |
'nodename' => '[', |
| 68 |
'nodetype' => ntypCDATA, |
| 69 |
}, |
| 70 |
'Embperl comment' => { |
| 71 |
'text' => '[#', |
| 72 |
'end' => '#]', |
| 73 |
# 'inside' => \%MetaComment, |
| 74 |
'procinfo' => { |
| 75 |
embperl => { |
| 76 |
compilechilds => 0, |
| 77 |
removenode => 3, |
| 78 |
}, |
| 79 |
}, |
| 80 |
}, |
| 81 |
'Embperl output msg id' => { |
| 82 |
'text' => '[=', |
| 83 |
'end' => '=]', |
| 84 |
'unescape' => 1, |
| 85 |
removespaces => 72, |
| 86 |
'procinfo' => { |
| 87 |
embperl => { |
| 88 |
perlcode => |
| 89 |
[ |
| 90 |
'$Embperl::Syntax::MsgIdExtract::Ids{%#\'0%} = q{} if (!exists ($Embperl::Syntax::MsgIdExtract::Ids{%#\'0%})) ;', |
| 91 |
], |
| 92 |
removenode => 4, |
| 93 |
compilechilds => 0, |
| 94 |
} |
| 95 |
}, |
| 96 |
}, |
| 97 |
'Embperl output msg id gettext' => { |
| 98 |
'text' => 'gettext', |
| 99 |
'end' => ')', |
| 100 |
'unescape' => 1, |
| 101 |
follow => { |
| 102 |
'bracktes' => |
| 103 |
{ |
| 104 |
'text' => '(', |
| 105 |
'end' => ')', |
| 106 |
follow => { |
| 107 |
'Quote ""' => |
| 108 |
{ |
| 109 |
'text' => '"', |
| 110 |
'end' => '"', |
| 111 |
removespaces => 72, |
| 112 |
'procinfo' => { |
| 113 |
embperl => { |
| 114 |
perlcode => |
| 115 |
[ |
| 116 |
'$Embperl::Syntax::MsgIdExtract::Ids{%#\'0%} = q{} if (!exists ($Embperl::Syntax::MsgIdExtract::Ids{%#\'0%})) ;', |
| 117 |
], |
| 118 |
removenode => 4, |
| 119 |
compilechilds => 0, |
| 120 |
} |
| 121 |
}, |
| 122 |
}, |
| 123 |
'Quote \'\'' => |
| 124 |
{ |
| 125 |
'text' => '\'', |
| 126 |
'end' => '\'', |
| 127 |
removespaces => 72, |
| 128 |
'procinfo' => { |
| 129 |
embperl => { |
| 130 |
perlcode => |
| 131 |
[ |
| 132 |
'$Embperl::Syntax::MsgIdExtract::Ids{%#\'0%} = q{} if (!exists ($Embperl::Syntax::MsgIdExtract::Ids{%#\'0%})) ;', |
| 133 |
], |
| 134 |
removenode => 4, |
| 135 |
compilechilds => 0, |
| 136 |
} |
| 137 |
}, |
| 138 |
}, |
| 139 |
}, |
| 140 |
}, |
| 141 |
}, |
| 142 |
}, |
| 143 |
) ; |
| 144 |
|
| 145 |
|
| 146 |
1; |
| 147 |
|
| 148 |
|
| 149 |
__END__ |
| 150 |
|
| 151 |
=pod |
| 152 |
|
| 153 |
=head1 NAME |
| 154 |
|
| 155 |
Embperl::Syntax::MsgIdExtract - define syntax for i18n using Embperl blocks |
| 156 |
|
| 157 |
=head1 SYNOPSIS |
| 158 |
|
| 159 |
|
| 160 |
=head1 DESCRIPTION |
| 161 |
|
| 162 |
Class derived from Embperl::Syntax to define the syntax for the |
| 163 |
internationalisation using "[= =]" Embperl blocks and metacommands. |
| 164 |
|
| 165 |
See L<Embperl>, section I18N for details. |
| 166 |
|
| 167 |
=head1 Methods |
| 168 |
|
| 169 |
I<Embperl::Syntax::MsgIdExtract> defines the following methods: |
| 170 |
|
| 171 |
=head2 Embperl::Syntax::MsgIdExtract -> new / $self -> new |
| 172 |
|
| 173 |
Create a new syntax class. This method should only be called inside a constructor |
| 174 |
of a derived class. |
| 175 |
|
| 176 |
|
| 177 |
=head2 AddMetaCmd ($cmdname, $procinfo) |
| 178 |
|
| 179 |
Add a new metacommand with name C<$cmdname> and use processor info from |
| 180 |
C<$procinfo>. See I<Embperl::Syntax> for a definition of procinfo. |
| 181 |
|
| 182 |
=head2 AddMetaCmdWithEnd ($cmdname, $endname, $procinfo) |
| 183 |
|
| 184 |
Add a new metacommand with name C<$cmdname> and use processor info from |
| 185 |
C<$procinfo>. Addtionaly specify that a matching C<$endname> metacommand |
| 186 |
must be found to end the block, that is started by this metacommand. |
| 187 |
See I<Embperl::Syntax> for a definition of procinfo. |
| 188 |
|
| 189 |
=head2 AddMetaCmdBlock ($cmdname, $endname, $procinfostart, $procinfoend) |
| 190 |
|
| 191 |
Add a new metacommand with name C<$cmdname> and and a second metacommand |
| 192 |
C<$endname> which ends the block that is started by C<$cmdname>. |
| 193 |
Use processor info from C<$procinfo>. |
| 194 |
See I<Embperl::Syntax> for a definition of procinfo. |
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
=head1 Author |
| 199 |
|
| 200 |
G. Richter (richter at embperl dot org) |
| 201 |
|
| 202 |
=head1 See Also |
| 203 |
|
| 204 |
Embperl::Syntax |
| 205 |
|
| 206 |
|