NAME
Locale::TextDomain::OO::Singleton::Lexicon - Provides singleton lexicon access
$Id: Lexicon.pm 698 2017-09-28 05:21:05Z steffenw $
$HeadURL: svn+ssh://steffenw@svn.code.sf.net/p/perl-gettext-oo/code/module/trunk/lib/Locale/TextDomain/OO/Singleton/Lexicon.pm $
VERSION
1.031
DESCRIPTION
This module provides the singleton lexicon access for Locale::TextDomain:OO.
SYNOPSIS
use Locale::TextDomain::OO::Singleton::Lexicon;
$lexicon_data = Locale::TextDomain::OO::Singleton::Lexicon->instance->data;
SUBROUTINES/METHODS
method new
exists but makes no sense
method instance
see SYNOPSIS
exists but makes no sense
method data
Get back the lexicon hash reference to fill the lexicon or to read from lexicon.
$lexicon_data = Locale::TextDomain::OO::Singleton::Lexicon->instance->data;
method merge_lexicon
Merge ist mostly used to join data of a language to create data for a region with some region different data.
The example means: Take 'de::' and overwrite with specials of 'de-at::' and store as 'de-at::'.
$instance->merge_lexicon('de::', 'de-at::', 'de-at::');
Maybe more clear writing:
$instance->merge_lexicon('de::', 'de-at::' => 'de-at::');
method copy_lexicon
Copy a lexicon is a special case. It is like merge without the 2nd parameter.
$instance->copy_lexicon('i-default::', 'i-default:LC_MESSAGES:domain');
Maybe more clear writing:
$instance->copy_lexicon('i-default::' => 'i-default:LC_MESSAGES:domain');
method move_lexicon
Move is typical used to move the "i-default::" lexicon into your domain and category. Using a lexicon without messages you are able to translate because the header with plural forms is set. With no lexicon you would get a missing "plural forms"-error during translation.
$instance->move_lexicon('i-default::', 'i-default:LC_MESSAGES:domain');
Maybe more clear writing:
$instance->move_lexicon('i-default::' => 'i-default:LC_MESSAGES:domain');
method delete_lexicon
Delete a lexicon from data.
$deleted_lexicon = $instance->delete_lexicon('de::');
method logger
Set the logger and get back them
$lexicon_hash->logger(
sub {
my ($message, $arg_ref) = @_;
my $type = $arg_ref->{type};
$log->$type($message);
return;
},
);
$logger = $lexicon_hash->logger;
$arg_ref contains
object => $lexicon_hash, # the object itself
type => 'debug',
event => 'lexicon,merge', # or 'lexicon,copy'
# or 'lexicon,move'
# or 'lexicon,delete'
EXAMPLE
Inside of this distribution is a directory named example. Run this *.pl files.
DIAGNOSTICS
confess
CONFIGURATION AND ENVIRONMENT
none
DEPENDENCIES
Locale::TextDomain::OO::Role::Logger
INCOMPATIBILITIES
not known
BUGS AND LIMITATIONS
none
SEE ALSO
AUTHOR
Steffen Winkler
LICENSE AND COPYRIGHT
Copyright (c) 2013 - 2017, Steffen Winkler <steffenw at cpan.org>
. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.