Locale::Handle::Pluggable - MooseX::Types::VariantTable based plugins for Locale::Maketext.
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.
s/extends/with/
# 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" );
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.
loc
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.
The variant table method.
Has an entry for Str.
Str
Calls maketext.
maketext
This makes a lot more sense as roles, but Moose::Meta::Role is unable to support custom role merging of MooseX::Types::VariantTable yet.
Yuval Kogman <nothingmuch@woobling.org>
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.
To install Locale::Handle::Pluggable, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Locale::Handle::Pluggable
CPAN shell
perl -MCPAN -e shell install Locale::Handle::Pluggable
For more information on module installation, please visit the detailed CPAN module installation guide.