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

NAME

Locale::Maketext::Lexicon - Use other catalog formats in Maketext

VERSION

This document describes version 0.12 of Locale::Maketext::Lexicon, released November 7, 2002.

SYNOPSIS

As part of a localization class:

    package Hello::L10N;
    use base 'Locale::Maketext';
    use Locale::Maketext::Lexicon {
        de => [Gettext => 'hello_de.po'],
        fr => [
            Gettext => 'hello_fr.po',
            Gettext => 'local/hello/fr.po',
        ],
    };

Alternatively, as part of a localization subclass:

    package Hello::L10N::de;
    use base 'Hello::L10N';
    use Locale::Maketext::Lexicon (Gettext => \*DATA);
    __DATA__
    # Some sample data
    msgid ""
    msgstr ""
    "Project-Id-Version: Hello 1.3.22.1\n"
    "MIME-Version: 1.0\n"
    "Content-Type: text/plain; charset=iso8859-1\n"
    "Content-Transfer-Encoding: 8bit\n"

    #: Hello.pm:10
    msgid "Hello, World!"
    msgstr "Hallo, Welt!"

    #: Hello.pm:11
    msgid "You have %quant(%1,piece) of mail."
    msgstr "Sie haben %quant(%1,Poststueck,Poststuecken)."

DESCRIPTION

This module provides lexicon-handling modules to read from other localization formats, such as Gettext, Msgcat, and so on.

If you are unfamiliar with the concept of lexicon modules, please consult Locale::Maketext and http://www.autrijus.org/webl10n/ first.

The import function

The import() function accepts two forms of arguments:

(format => [ filehandle | filename | arrayref ] ... )

This form takes any number of argument pairs (usually one). For each such pair, it pass the contents specified by the second argument to Locale::Maketext::Lexicon::format->parse as a plain list, and export its return value as the %Lexicon hash in the calling package.

In the case that there are multiple such pairs, the lexicon defined by latter ones overrides earlier ones.

{ language => [ format, [ filehandle | filename | arrayref ] ... ] ... }

This form accepts a hash reference. It will export a %Lexicon into the subclasses specified by each language, using the process described above. It is designed to alleviate the need to set up a separate subclass for each localized language, and just use the catalog files.

Subclassing format handlers

If you wish to override how sources specified in different data types are handled, please use a subclass that overrides lexicon_get_TYPE.

XXX: not documented well enough yet. Patches welcome.

NOTES

If you want to implement a new Lexicon::* backend module, please note that parse() takes an array containing the source strings from the specified filehandle or filename, which are not chomped. Although if the source is an array reference, its elements will probably not contain any newline characters anyway.

The parse() function should return a hash reference, which will be assigned to the typeglob (*Lexicon) of the language module. All it amounts to is that if the returned reference points to a tied hash, the %Lexicon will be aliased to the same tied hash if it was not initialized previously.

ACKNOWLEDGMENTS

Thanks to Jesse Vincent for suggesting this module to be written.

Thanks also to Sean M. Burke for coming up with Locale::Maketext in the first place, and encouraging me to experiment with alternative Lexicon syntaxes.

See the AUTHORS file in the distribution for a list of people who have sent helpful patches, ideas or comments.

SEE ALSO

Locale::Maketext, Locale::Maketext::Lexicon::Auto, Locale::Maketext::Lexicon::Gettext, Locale::Maketext::Lexicon::Msgcat, Locale::Maketext::Lexicon::Tie

AUTHORS

Autrijus Tang <autrijus@autrijus.org>

COPYRIGHT

Copyright 2002 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