CatalystX::I18N::Model::Maketext - Glues Locale::Maketext into Catalyst
# In your catalyst base class package MyApp::Catalyst; use Catalyst qw/CatalystX::I18N::Role::Base/; __PACKAGE__->config( 'Model::Maketext' => { class => 'MyApp::Maketext', # optional directories => '/path/to/maketext/files', # optional }, ); # Create a model class package MyApp::Model::Maketext; use parent qw/CatalystX::I18N::Model::Maketext/; # Create a Maketext class (must be a Locale::Maketext class) package MyApp::Maketext; use parent qw/CatalystX::I18N::Maketext/; # In your controller class(es) package MyApp::Controller::Main; use parent qw/Catalyst::Controller/; sub action : Local { my ($self,$c) = @_; my $model = $c->model('Maketext'); $c->stash->{title} = $model->maketext('Hello world'); # See CatalystX::I18N::Role::Maketext for a convinient wrapper }
This model glues a Locale::Maketext class (eg. CatalystX::I18N::Maketext) into you Catalyst application.
The method fail_with will be called for each missing msgid if present in your model class.
fail_with
package MyApp::Model::Maketext; use parent qw/CatalystX::I18N::Model::Maketext/; sub fail_with { my ($self,$c,$language_handle,$msgid,$params) = @_; # Do somenthing clever return $string; }
See Catalyst::Helper::Model::Maketext for gerating an Maketext model from the command-line.
Set the Locale::Maketext class you want to use from this model.
Defaults to $APPNAME::Maketext
Enable gettext style. %quant(%1,document,documents) instead of [quant,_1,document,documents]
%quant(%1,document,documents)
[quant,_1,document,documents]
Default TRUE
Array reference of directories to be searched for maketext files.
See CatalystX::I18N::Maketext for more details on the directory parameter
directory
CatalystX::I18N::Maketext, Locale::Maketext, Locale::Maketext::Lexicon and CatalystX::I18N::Role::Maketext
Maroš Kollár CPAN ID: MAROS maros [at] k-1.com L<http://www.k-1.com>
To install CatalystX::I18N, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CatalystX::I18N
CPAN shell
perl -MCPAN -e shell install CatalystX::I18N
For more information on module installation, please visit the detailed CPAN module installation guide.