Catalyst::Plugin::Activator::Dictionary : Provide a Catalyst context Activator::Dictionary lookup() function, and template lookup magic.
lookup()
# in MyApp.pm use Catalyst qw/ Activator::Dictionary /; # Configure Activator::Dictionary # Later, in some controller: my $msg = $c->lookup( 'look_me_up' ); # Even later, in some template: <p>%{look_me_up_too}</p>
This Catalyst plugin provides a lookup subroutine and a template shortcut syntax for Activator::Dictionary.
Gets the value for a key (using Activator::Dictionary lookup() sub) wherever you have access to the catalyst context object $c.
$c
Since Activator::Dictionary provides different realms, we default this plugin to the web realm:
# uses web realm $c->lookup('dict_key');
However, we can use any other realm we desire:
$c->lookup('dict_key', 'error'); $c->lookup('dict_key', 'other_realm');
When using this plugin from templates, we provide a special syntax for automated lookups.
During the finalize stage of the Catalyst execution stack, this plugin does a regular expression replacement of %{} formatted keys into dictionary lookups from the web realm.
%{}
web
Example:
In /path/to/dictionary/en/web.dict:
/path/to/dictionary/en/web.dict
nice_para This is a nice paragraph.
In a template:
<p>%{nice_para}</p>
Resulting HTML:
<p>This is a nice paragraph.</p>
Activator::Dictionary, Catalyst, Catalyst::Manual::Plugins
Karim A. Nassar
Copyright (c) 2007 Karim A. Nassar <karim.nassar@acm.org>
You may distribute under the terms of either the GNU General Public License, or the Artistic License as specified in the Perl README file.
To install Activator, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Activator
CPAN shell
perl -MCPAN -e shell install Activator
For more information on module installation, please visit the detailed CPAN module installation guide.