Daisuke Maki > Catalyst-Model-Data-Localize-0.00007 > Catalyst::Model::Data::Localize

Download:
Catalyst-Model-Data-Localize-0.00007.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Module Version: 0.00007   Source  

NAME ^

Catalyst::Model::Data::Localize - Catalyst Model Over Data::Localize

SYNOPSIS ^

    $c->model('Data::Localize') # or Localize. whatever
      ->localize($key, @args);

DESCRIPTION ^

WARNING: Data::Localize, which this module is based on, is still in alpha quality. This module should also be treated as such.

This is a thin wrapper around Data::Localize. The only thing it does that a plain Catalyst::Model::Adaptor + Data::Localize can do is the automatic discovery of I18N files (if they are placed under likely locations).

For example, these files will automatically be found:

    # suppose our Catalyst app is at  lib/MyApp.pm
    lib/MyApp/I18N/ja.pm
    lib/MyApp/I18N/ja.po

Also, for those like me that don't like to put a catalyst app at the project's top namespace, we look for one level above, too:

    # suppose our Catalyst app is at  lib/MyApp/Web.pm
    lib/MyApp/I18N/ja.pm
    lib/MyApp/I18N/ja.po

The default behavior is to detect the language setting from the HTTP headers. If you want to override it, simply place an explicit call somehwere in your action chain:

    my $loc = $c->model('Data::Localize');
    $loc->set_languages('ja'); # or whatever you prefer
    $loc->localize($key, @args);

CONFIGURATION ^

Configuration can be done via the 'Model::Data::Localize' slot:

    <Model::Data::Localize>
        auto 1
        <localizers>
            class Gettext
            path  /path/to/gettext/files/*.po
        </localizers>
    </Model::Data::Localize>

If you want Catalyst::Plugin::I18N compatible style method generation on the context object, look at Catalyst::Plugin::Data::Localize, which is just a really thin wrapper over this module.

languages parameter is a bit special, as it overrides the default behavior to detect the desired language from HTTP headers.

    # Always use ja
    <Model::Data::Localize>
        languages ja
    </Model::Data::Localize>

TODO ^

Tests. Yes, I know.

AUTHOR ^

Daisuke Maki <daisuke@endeworks.jp>

LICENSE ^

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See http://www.perl.com/perl/misc/Artistic.html

syntax highlighting: