NAME
Locale::TextDomain::OO::Extract::Xslate - Extract messages from Text::Xslate templates for translation with Locale::TextDomain::OO
VERSION
version 0.01
SYNOPSIS
use Locale::TextDomain::OO::Extract::Xslate;
use Locale::TextDomain::OO::Extract::Process;
my $process = Locale::TextDomain::OO::Extract::Process->new();
my $extract = Locale::TextDomain::OO::Extract::Xslate->new();
# extract
for my $file (qw( foo.tx bar.tx )) {
$extract->clear;
$extract->filename($file);
$extract->extract;
}
# merge
for my $language (qw( de en )) {
$process->language($language);
$process->merge_extract({
lexicon_ref => $extract->lexicon_ref,
});
}
DESCRIPTION
Locale::TextDomain::OO::Extract::Xslate extracts messages from Text::Xslate templates for later translation handling with Locale::TextDomain::OO.
The template code is scanned for invocations of methods or functions with certain names. Currently the following names are recognized:
The same methods are recognized when the first _ (underscore) is replaced by loc (resulting in loc_, loc_x, and so on).
Both variants can also optionally be prefixed by N.
For the encoded meaning of these names please refer to Locale::TextDomain::OO::Plugin::Expand::Gettext and Locale::TextDomain::OO::Plugin::Expand::Gettext::Loc, respectively.
Please note that as of now the usage of dynamic domains and/or categories (as provided by Locale::TextDomain::OO::Plugin::Expand::Gettext::DomainAndCategory) is not supported!
CONSTRUCTOR OPTIONS
The following params can be provided to the plugin on object construction:
syntax-
Specify the syntax used in the templates to be scanned. Acceptable values are
debug-
Passing in a true value for this option enables a dumping (to STDERR) of the abstract syntax tree of the template. This is mostly useful for the development of this module.
METHODS
Locale::TextDomain::OO::Extract::Xslate DOES the role Locale::TextDomain::OO::Extract::Role::File and therefore you can call the methods defined in that role on the objects of this class.
extract
After using the filename method to specify which template to work on next, invoking this method will start the extraction process. Expects no parameters.
debug
Passing in a true or false value you can enable or disable the debugging output (written to STDERR).
SEE ALSO
- Locale::TextDomain::OO
- Locale::TextDomain::OO::Extract
- Locale::TextDomain::OO::Extract::Process
- Locale::TextDomain::OO::Extract::Role::File
The code of this module and the way it uses the AST from Text::Xslate itself to identify the messages is heavily inspired by (read: stolen from) Localizer::Scanner::Xslate.
AUTHOR
Heiko Jansen <hjansen@cpan.org>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2015 by Heiko Jansen <hjansen@cpan.org>.
This is free software, licensed under:
The GNU General Public License, Version 3, June 2007