Template::Plugin::Lingua::EN::Inflexion - Interface to Lingua::EN::Inflexion module
use strict; use warnings; use Template; my $tsrc = <<'EOT'; [% USE infl = Lingua.EN.Inflexion; -%] [% FOR obj IN objects; -%] [% FOR n IN [0, 1, 2]; -%] [% FILTER inflect; -%] <#d:$n>There <V:was> <#n:$n> <N:$obj.name>. [% IF n > 0 %] <A:This> <N:$obj.name> <V:was> ${obj.colour}. [% END; END; END %] [% END; -%] EOT my $data = { objects => [ { name => 'dog', colour => 'brown' }, { name => 'goose', colour => 'white' }, { name => 'fish', colour => 'gold' } ] }; my $template = Template->new ({INTERPOLATE => 1}); $template->process (\$tsrc, $data);
The Lingua::EN::Inflexion Plugin is an interface to Damian Conway's Lingua::EN::Inflexion Perl module, which provides plural inflections, "a"/"an" selection for English words, and manipulation of numbers as words. The plugin provides an 'inflect' filter, which can be used to interpolate inflections in a string.
For the full gory details of the inflection functionality refer to the Lingua::EN::Inflexion manual.
my $infl = Template::Plugin::Lingua::EN::Inflexion->new ($context);
The constructor takes one argument which is the context on which the filter will be defined and returns the new object. You will not need to call this explicitly within a template, just USE the plugin as normal:
[% USE infl = Lingua.EN.Inflexion; -%]
my $plural = $infl->noun ('dog')->plural;
The noun method is a wrapper around Lingua::EN::Inflexion::noun() and returns an object of Lingua::EN::Inflexion::Noun.
Lingua::EN::Inflexion::noun()
my $plural = $infl->verb ('dog')->plural;
The verb method is a wrapper around Lingua::EN::Inflexion::verb() and returns an object of Lingua::EN::Inflexion::Verb.
Lingua::EN::Inflexion::verb()
my $plural = $infl->adj ('canine')->plural;
The adj method is a wrapper around Lingua::EN::Inflexion::adj() and returns an object of Lingua::EN::Inflexion::Adj.
Lingua::EN::Inflexion::adj()
my $list = $class->wordlist (@fruits);
The wordlist method is a wrapper around Lingua::EN::Inflexion::wordlist() and returns a scalar string.
Lingua::EN::Inflexion::wordlist()
tt_inflect ($string)
The underlying inflect filter.
Lingua::EN::Inflexion, Template, Template::Plugin, Template::Plugin::Lingua::EN::Inflect
Written and maintained by Pete Houston.
This module was inspired by and borrows very heavily from Template::Plugin::Lingua::EN::Inflect, originally written by Andrew Ford and maintained by Barbie.
Damian Conway <damian@conway.org> wrote the Lingua::EN::Inflexion module, which does all the heavy lifting.
Parts of Template::Plugin::Lingua::EN::Inflect retained here are
Template::Plugin::Lingua::EN::Inflect
Copyright © 2005-2014 Andrew Ford
Copyright © 2014-2015 Barbie for Miss Barbell Productions
Other works are
Copyright © 2019-2020 Pete Houston
This distribution is free software; you can redistribute it and/or modify it under the Artistic Licence v2.
To install Template::Plugin::Lingua::EN::Inflexion, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Template::Plugin::Lingua::EN::Inflexion
CPAN shell
perl -MCPAN -e shell install Template::Plugin::Lingua::EN::Inflexion
For more information on module installation, please visit the detailed CPAN module installation guide.