Locale::TextDomain::OO::Lexicon::File::MO - Gettext mo file as lexicon
$Id: MO.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/Lexicon/File/MO.pm $
1.031
This module reads a gettext mo file into the lexicon.
use Locale::TextDomain::OO::Lexicon::File::MO; use Log::Any qw($log); $logger = Locale::TextDomain::OO::Lexicon::File::MO ->new( # all parameters are optional decode_code => sub { my ($charset, $text) = @_; defined $text or return $text; return decode( $charset, $text ); }, # optional logger => sub { my ($message, $arg_ref) = @_; my $type = $arg_ref->{type}; # debug $log->$type($message); return; }, ) ->lexicon_ref({ # required search_dirs => [ qw( ./my_dir ./my_other_dir ) ], # optional gettext_to_maketext => $boolean, # optional decode => $boolean, # required data => [ # e.g. de.mo, en.mo read from: # search_dir/de.mo # search_dir/en.mo '*::' => '*.mo', # e.g. de.mo en.mo read from: # search_dir/subdir/de/LC_MESSAGES/domain.mo # search_dir/subdir/en/LC_MESSAGES/domain.mo '*:LC_MESSAGES:domain' => 'subdir/*/LC_MESSAGES/domain.mo', # Merge a region lexicon: # Take the header and messages of the "de::" lexicon, # overwrite the header and messages of the "de-at::" lexicon # and store that as "de-at::" lexicon with all messages now. merge_lexicon => 'de::', 'de-at::' => 'de-at::', # Copy a lexicon into another domain and/or category: copy_lexicon => 'i-default::' => 'i-default:LC_MESSAGES:domain', # Move a lexicon into another domain and/or category: move_lexicon => 'i-default::' => 'i-default:LC_MESSAGES:domain', # Delete a lexicon: delete_lexicon => 'i-default::', ], }) ->logger;
see SYNOPSIS
See SYNOPSIS.
Called from Locale::TextDomain::OO::Lexicon::Role::File to run the mo file specific code.
$messages_ref = $self->read_messages($filename);
Set the logger and get back them
$lexicon_file_mo->logger( sub { my ($message, $arg_ref) = @_; my $type = $arg_ref->{type}; $log->$type($message); return; }, ); $logger = $lexicon_hash->logger;
$arg_ref contains
object => $lexicon_file_mo, # the object itself type => 'debug', event => 'lexicon,load', # The logger will be copied to # Locale::TextDomain::OO::Singleton::Lexicon # so more events are possible.
Inside of this distribution is a directory named example. Run this *.pl files.
none
Locale::MO::File
Moo
MooX::StrictConstructor
Locale::TextDomain::OO::Lexicon::Role::File
not known
Locale::TextDoamin::OO
Steffen Winkler
Copyright (c) 2013 - 2017, Steffen Winkler <steffenw at cpan.org>. All rights reserved.
<steffenw at cpan.org>
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Locale::TextDomain::OO, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Locale::TextDomain::OO
CPAN shell
perl -MCPAN -e shell install Locale::TextDomain::OO
For more information on module installation, please visit the detailed CPAN module installation guide.