NAME
Localizer::Lexicon - Default lexicon class
SYNOPSIS
use Localizer::Resource;
use Localizer::Style::Gettext;
use Localizer::Lexicon
my $es = Localizer::Resource->new(
dictionary => Localizer::Lexicon->new( 'Hi, %1.' => 'Hola %1.' ),
format => Localizer::Style::Gettext->new(),
);
say $es->maketext("Hi, %1.", "John"); # => Hola, John.
DESCRIPTION
Localizer::Lexicon is just the default lexicon that is built internally when you provide a hashref as your dictionary.
You can implement your own class to replace this one as your Localizer dictionary, for instance, to get your translations from a database or API. Just pass your object which implements msgids() and msgstr() like this one as your dictionary.
METHODS
Localizer::Lexicon->new(%args | \%args)
Constructor. It will initialize the lexicon from a list or hashref
e.g.
my $de = Localizer::Lexicon->new( 'Hello, World!' => 'Hello, Welt!' );
$localizer->msgids();
Returns a list of msgeid's which are the keys of the dictionary.
$localizer->msgstr($msgid);
Return the message to translate given $msgid (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.