NAME

Template::Plugin::Lingua::EN::Inflexion - Interface to Lingua::EN::Inflexion module

SYNOPSIS

  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);

DESCRIPTION

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.

METHODS

new

    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; -%]

noun

    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.

verb

    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.

adj

    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.

wordlist

    my $list = $class->wordlist (@fruits);

The wordlist method is a wrapper around Lingua::EN::Inflexion::wordlist() and returns a scalar string.

INTERNAL METHODS

tt_inflect ($string)

The underlying inflect filter.

SEE ALSO

Lingua::EN::Inflexion, Template, Template::Plugin, Template::Plugin::Lingua::EN::Inflect

AUTHOR

Written and maintained by Pete Houston.

ACKNOWLEDGEMENTS

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.

COPYRIGHT & LICENSE

Parts of Template::Plugin::Lingua::EN::Inflect retained here are

    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.