Localizer::Resource - Interface to manipulate Localizer
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)
Localizer is the yet another framework for localization. It is more simple than past localization framework.
This module is the interface to manipulate Localizer.
Localizer::Resource->new(%args | \%args)
Constructor. It makes Localizer client with %args.
%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 data to localize.
Format of dictionary. Now this module supports Localizer::Style::Gettext (Gettext style) and Localizer::Style::Maketext (Maketext style). Default value is Localizer::Style::Gettext.
Register functions to call by dictionary. Please see also Localizer::Style::Gettext and Localizer::Style::Maketext.
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.
Locale::Maketext, Locale::Maketext::Lexicon
Copyright (C) Tokuhiro Matsuno.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Localizer, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Localizer
CPAN shell
perl -MCPAN -e shell install Localizer
For more information on module installation, please visit the detailed CPAN module installation guide.