NAME
CatalystX::I18N::Model::L10N - Glues CatalystX::I18N::L10N into Catalyst
SYNOPSIS
# In your catalyst base class
package MyApp::Catalyst;
use Catalyst qw/CatalystX::I18N::Role::Base/;
__PACKAGE__->config(
'Model::L10N' => {
directory => '/path/to/l10n/files', # optional
},
);
# Create a model class
package MyApp::Model::L10N;
use parent qw/CatalystX::I18N::Model::L10N/;
# Create a L10N class (must be a Locale::Maketext class)
package MyApp::L10N;
use parent qw/CatalystX::I18N::L10N/;
# In your controller class(es)
package MyApp::Controller::Main;
use parent qw/Catalyst::Controller/;
sub action : Local {
my ($self,$c) = @_;
my $model = $c->model('L10N');
$c->stash->{title} = $model->maketext('Hello world');
# See CatalystX::I18N::Role::Maketext for a convinient wrapper
}
DESCRIPTION
This model glues a CatalystX::I18N::L10N class (or any other Locale::Maketext class) with Catalyst.
The method fail_with
will be called for each missing msgid if present in your model class.
package MyApp::Model::L10N;
use parent qw/CatalystX::I18N::Model::L10N/;
sub fail_with {
my ($self,$c,$language_handle,$msgid,$params) = @_;
# Do somenthing clever
return $string;
}
See Catalyst::Helper::Model::L10N for gerating an L10N model from the command-line.
CONFIGURATION
class
Set the Locale::Maketext class you want to use from this model.
Defaults to $APPNAME::L10N
gettext_style
Enable gettext style. %quant(%1,document,documents)
instead of [quant,_1,document,documents]
Default TRUE
directory
List of directories to be searched for L10N files.
See CatalystX::I18N::L10N for more details on the directory
parameter
SEE ALSO
CatalystX::I18N::L10N, Locale::Maketext, Locale::Maketext::Lexicon and CatalystX::I18N::Role::Maketext
AUTHOR
Maroš Kollár
CPAN ID: MAROS
maros [at] k-1.com
L<http://www.revdev.at>