Git Product home page Git Product logo

locale-textdomain-oo-extract-xslate's Introduction

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:

__ (double underscore)
__x
__n
__nx
__p
__px
__np
__npx

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.

Texts to be translated are also recognized and extracted where filters with these names are used. But please note that since filters cannot take arguments, only __ and loc_ (and perhaps some custom methods; cf. addl_l10n_function_re below) may reasonably be used as filters!

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

Text::Xslate::Syntax::Kolon (also the default)
Text::Xslate::Syntax::Metakolon
Text::Xslate::Syntax::TTerse
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.

addl_l10n_function_re

If you need to extract more than the default list of translation functions, you can add yours with this, e.g.

$extract->addl_l10n_function_re(qr{ loc | i10n_me | whatever }x);

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.

locale-textdomain-oo-extract-xslate's People

Contributors

heikojansen avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.