CPANPLUS
view release on metacpan or search on metacpan
inc/bundle/Locale/Maketext/Simple.pm view on Meta::CPAN
package Locale::Maketext::Simple;
$Locale::Maketext::Simple::VERSION = '0.21';
use strict;
use 5.005;
=head1 NAME
Locale::Maketext::Simple - Simple interface to Locale::Maketext::Lexicon
=head1 VERSION
This document describes version 0.18 of Locale::Maketext::Simple,
released Septermber 8, 2006.
=head1 SYNOPSIS
Minimal setup (looks for F<auto/Foo/*.po> and F<auto/Foo/*.mo>):
package Foo;
use Locale::Maketext::Simple; # exports 'loc'
loc_lang('fr'); # set language to French
sub hello {
print loc("Hello, [_1]!", "World");
}
More sophisticated example:
package Foo::Bar;
use Locale::Maketext::Simple (
Class => 'Foo', # search in auto/Foo/
Style => 'gettext', # %1 instead of [_1]
Export => 'maketext', # maketext() instead of loc()
Subclass => 'L10N', # Foo::L10N instead of Foo::I18N
Decode => 1, # decode entries to unicode-strings
Encoding => 'locale', # but encode lexicons in current locale
# (needs Locale::Maketext::Lexicon 0.36)
);
sub japh {
print maketext("Just another %1 hacker", "Perl");
}
=head1 DESCRIPTION
This module is a simple wrapper around B<Locale::Maketext::Lexicon>,
designed to alleviate the need of creating I<Language Classes> for
module authors.
The language used is chosen from the loc_lang call. If a lookup is not
possible, the i-default language will be used. If the lookup is not in the
i-default language, then the key will be returned.
If B<Locale::Maketext::Lexicon> is not present, it implements a
minimal localization function by simply interpolating C<[_1]> with
the first argument, C<[_2]> with the second, etc. Interpolated
function like C<[quant,_1]> are treated as C<[_1]>, with the sole
exception of C<[tense,_1,X]>, which will append C<ing> to C<_1> when
X is C<present>, or appending C<ed> to <_1> otherwise.
=head1 OPTIONS
All options are passed either via the C<use> statement, or via an
explicit C<import>.
=head2 Class
By default, B<Locale::Maketext::Simple> draws its source from the
calling package's F<auto/> directory; you can override this behaviour
by explicitly specifying another package as C<Class>.
=head2 Path
If your PO and MO files are under a path elsewhere than C<auto/>,
you may specify it using the C<Path> option.
=head2 Style
By default, this module uses the C<maketext> style of C<[_1]> and
C<[quant,_1]> for interpolation. Alternatively, you can specify the
C<gettext> style, which uses C<%1> and C<%quant(%1)> for interpolation.
This option is case-insensitive.
=head2 Export
By default, this module exports a single function, C<loc>, into its
caller's namespace. You can set it to another name, or set it to
an empty string to disable exporting.
=head2 Subclass
By default, this module creates an C<::I18N> subclass under the
caller's package (or the package specified by C<Class>), and stores
lexicon data in its subclasses. You can assign a name other than
C<I18N> via this option.
( run in 0.747 second using v1.01-cache-2.11-cpan-39bf76dae61 )