Locale::Maketext::Extract::Plugin::Mason - Mason format parser


Locale-Maketext-Lexicon documentation Contained in the Locale-Maketext-Lexicon distribution.

Index


Code Index:

NAME

Top

Locale::Maketext::Extract::Plugin::Mason - Mason format parser

SYNOPSIS

Top

    $plugin = Locale::Maketext::Extract::Plugin::Mason->new(
        $lexicon            # A Locale::Maketext::Extract object
        @file_types         # Optionally specify a list of recognised file types
    )

    $plugin->extract($filename,$filecontents);

DESCRIPTION

Top

Extracts strings to localise from Mason files.

SHORT PLUGIN NAME

Top

    mason

VALID FORMATS

Top

Strings inside <&|/l>...</&> and <&|/loc>...</&> are extracted.

KNOWN FILE TYPES

Top

All file types

SEE ALSO

Top

xgettext.pl

for extracting translatable strings from common template systems and perl source files.

Locale::Maketext::Lexicon
Locale::Maketext::Extract::Plugin::Base
Locale::Maketext::Extract::Plugin::FormFu
Locale::Maketext::Extract::Plugin::Perl
Locale::Maketext::Extract::Plugin::TT2
Locale::Maketext::Extract::Plugin::YAML
Locale::Maketext::Extract::Plugin::TextTemplate
Locale::Maketext::Extract::Plugin::Generic

AUTHORS

Top

Audrey Tang <cpan@audreyt.org>

COPYRIGHT

Top

The "MIT" License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


Locale-Maketext-Lexicon documentation Contained in the Locale-Maketext-Lexicon distribution.
package Locale::Maketext::Extract::Plugin::Mason;

use strict;
use base qw(Locale::Maketext::Extract::Plugin::Base);

sub file_types {
    return qw( * );
}


sub extract {
    my $self = shift;
    local $_ = shift;

    my $line = 1;

    # HTML::Mason

    while (m!\G(.*?<&\|/l(?:oc)?(.*?)&>(.*?)</&>)!sg) {
        my ($vars, $str) = ($2, $3);
        $line += ( () = ($1 =~ /\n/g) ); # cryptocontext!
        $self->add_entry($str,  $line, $vars );
    }

}


1;