The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Locale::Maketext::Simple - Simple interface to Locale::Maketext::Lexicon

VERSION

This document describes version 0.01 of Locale::Maketext::Simple, released May 10, 2003.

SYNOPSIS

Minimal setup (looks for auto/Foo/*.po and auto/Foo/*.mo):

    package Foo;
    use Locale::Maketext::Simple;       # exports 'loc'
    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
    );
    sub japh {
        print maketext("Just another %1 hacker", "Perl");
    }

DESCRIPTION

This module is a simple wrapper around Locale::Maketext::Lexicon, designed to alleviate the need of creating Language Classes for module authors.

If Locale::Maketext::Lexicon is not present, it implements a minimal localization function by simply interpolating [_1] with the first argument, [_2] with the second, etc. Interpolated function like [quant,_1] are treated as [_1].

OPTIONS

All options are passed to import.

Class

By default, Locale::Maketext::Simple draws its source from the calling package's auto/ directory; you can override this behaviour by explicitly specifying another package as Class.

Style

By default, this module uses the maketext style of [_1] and [quant,_1] for interpolation. Alternatively, you can specify the gettext style, which uses %1 and %quant(%1) for interpolation.

This option is case-insensitive.

Export

By default, this module exports a single function, loc, into its caller's namespace. You can set it to another name, or set it to an empty string to disable exporting.

Subclass

By default, this module creates a ::I18N subclass under the caller's package (or the package specified by Class), and stores lexicon data in its subclasses. You can assign a name other than I18N via this option.

ACKNOWLEDGMENTS

Thanks to Jos I. Boumans for suggesting this module to be written.

SEE ALSO

Locale::Maketext, Locale::Maketext::Lexicon

AUTHORS

Autrijus Tang <autrijus@autrijus.org>

COPYRIGHT

Copyright 2003 by Autrijus Tang <autrijus@autrijus.org>.

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