/usr/share/perl5/Dist/Zilla/Plugin/LocaleMsgfmt.pm is in libdist-zilla-plugin-localemsgfmt-perl 1.203-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | package Dist::Zilla::Plugin::LocaleMsgfmt;
BEGIN {
$Dist::Zilla::Plugin::LocaleMsgfmt::VERSION = '1.203';
}
# ABSTRACT: compiles .po files to .mo files with Local::Msgfmt
use Locale::Msgfmt 0.14;
use Moose;
use MooseX::Has::Sugar;
use Path::Class;
with 'Dist::Zilla::Role::BeforeBuild';
# -- attributes
# For Config::MVP - specify setting names that may have multiple values and that will always
# be stored in an arrayref
sub mvp_multivalue_args { qw(locale) }
has recursive => ( ro, isa=>'Bool', default=>1 );
has locale => (
ro, lazy, auto_deref,
isa => 'ArrayRef[Str]',
default => sub {
my $self = shift;
my $path = dir( $self->zilla->root, 'share', 'locale' );
return -e $path ? [ $path ] : [ ];
},
);
# -- public methods
#
# to implement Dist::Zilla::Role::BeforeBuild
sub before_build {
my ( $self, $args ) = @_;
for my $dir ( $self->locale ) {
my $path = dir($dir);
if ( ! -e $path ) {
warn "Skipping invalid path: $path";
next;
}
# find directories if recursive behaviour wanted
my @pathes;
if ( $self->recursive ) {
$path->recurse(
callback => sub {
my $p = shift;
push @pathes, $p if -d $p;
}
);
} else {
push @pathes, $path;
}
# generating mo files
foreach my $p ( @pathes ) {
$self->log("Generating .mo files from .po files in $p");
msgfmt( { in => $p->absolute, verbose => 1, remove => 0 } );
}
}
}
__PACKAGE__->meta->make_immutable;
no Moose;
1;
=pod
=head1 NAME
Dist::Zilla::Plugin::LocaleMsgfmt - compiles .po files to .mo files with Local::Msgfmt
=head1 VERSION
version 1.203
=head1 DESCRIPTION
Put the following in your S<F<dist.ini> :>
[LocaleMsgfmt]
locale = share/locale ; this is the default
This plugin will compile all of the .po files it finds in the locale directory into .mo
files, via Locale::Msgfmt.
=head1 ATTRIBUTES
=head2 recursive
Whether to look up in the locale files recursively.
=head2 locale
Path to the directory containing the locale files.
=for Pod::Coverage before_build
mvp_multivalue_args
=head1 TODO
Remove the generated files after the build finishes, or better yet do the generation inside
the build dir.
=head1 AUTHOR
Patrick Donelan <pdonelan@cpan.org>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Patrick Donelan.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
__END__
|