The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Locale::Handle::Pluggable - MooseX::Types::VariantTable based plugins for Locale::Maketext.

VERSION

This code WILL change in the future.

Role support is still not available for MooseX::Types::VariantTable, and when that will be added (kinda tricky) everything will change from class based to role based.

Once that is in this shouldn't involve much more than s/extends/with/, but be aware that your code may break.

SYNOPSIS

    # create the localization factory class
    # see Locale::Maketext for details

        package MyProgram::L10N;
    use Moose;

    # define the factory class normally
    extends qw(Locale::Maketext);
    # or
    use Locale::Maketext::Lexicon { ... };


    # load some additional roles... uh i mean classes with variants for the loc() method
    extends qw(
        Locale::Maktext
    
        Locale::Maketext::Pluggable
        Locale::Maketext::Pluggable::DateTime
        Locale::Maketext::Pluggable::Foo
    );




    # in your language definitions, use Locale::Maketext's syntax for entries
    # For instance, to create a localized greeting with a date, the entries
    # might look like the following example. the second argument to %loc() is
    # the DateTime::Locale format symbolic format name

    # English:
    'Hello, it is now [loc, _1, "full_time"]'
    # in gettext style:
    'Hello, it is now %loc(%1, "full_time")'

    # Hebrew:
    'שלום, השעה [loc, _1, "medium_time"]'


    # And then use it like this:
    $handle->loc( $message_id, $datetime_object ); # the datetime object is in %1


    # this also works, since %loc is a method call on the language handle:
    $handle->loc( $datetime_object, "short_date" );
    

DESCRIPTION

This class extends the Locale::Maketext api to provide a loc method, that attempts to be able to localize "anything", where "anything" is defined in the various plugin methods loaded.

The dispatch table for the various types is constructed using MooseX::Types::VariantTable::Declare, and each plugin can provide additional Moose::Util::TypeConstraints based extensions.

METHODS

loc $thing, @args

The variant table method.

Has an entry for Str.

loc_string $msgid, @args

Calls maketext.

TODO

This makes a lot more sense as roles, but Moose::Meta::Role is unable to support custom role merging of MooseX::Types::VariantTable yet.

AUTHOR

Yuval Kogman <nothingmuch@woobling.org>

COPYRIGHT

        Copyright (c) 2008 Infinity Interactive, Yuval Kogman. All rights
    reserved This program is free software; you can redistribute
        it and/or modify it under the same terms as Perl itself.