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

NAME

Localizer::Resource - Interface to manipulate Localizer

SYNOPSIS

    use Localizer::Resource;
    use Localizer::Style::Gettext;
    use Config::Properties;

    my $ja = Localizer::Resource->new(
        dictionary => +{ Config::Properties->new(
            file => 'ja.properties'
        )->properties },
        format => Localizer::Style::Gettext->new(),
        functions => {
            dubbil => sub { return $_[0] * 2 },
        },
    );
    say $ja->maketext("Hi, %1.", "John");        # => こんにちは、John。
    say $ja->maketext("Double: %dubbil(%1)", 7); # => 2倍: 14

Example of contents of ja.properties, like so;

    Hi,\ %1.=こんにちは、%1。
    Double\:\ %dubbil(%1)=2倍:\ %dubbil(%1)

DESCRIPTION

Localizer is the yet another framework for localization. It is more simple than past localization framework.

This module is the interface to manipulate Localizer.

METHODS

  • Localizer::Resource->new(%args | \%args)

    Constructor. It makes Localizer client with %args.

    e.g.

        my $de = Localizer::Resource->new(
            dictionary => {
                'Hello, World!' => 'Hello, Welt!'
            }
            format => Localizer::Style::Gettext->new(),
            functions => {
                dubbil => sub { return $_[0] * 2 },
            },
            precompile => 0,
        );
    dictionary: Hash Reference

    Dictionary data to localize.

    format: Instance of Style Class

    Format of dictionary. Now this module supports Localizer::Style::Gettext (Gettext style) and Localizer::Style::Maketext (Maketext style). Default value is Localizer::Style::Gettext.

    functions: Hash Reference

    Register functions to call by dictionary. Please see also Localizer::Style::Gettext and Localizer::Style::Maketext.

    precompile: Scalar Value

    It precompiles dictionary data if this value is true. Default value is 1 (means always precompile).

  • $localizer->maketext($key);

    Localize by dictionary data with key. If you give nonexistent key to this method, it returns undef.

SEE ALSO

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

LICENSE

Copyright (C) Tokuhiro Matsuno.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.