Skip to content

Commit

Permalink
pod & comment updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jquelin committed May 20, 2011
1 parent 1eead0e commit 170f15f
Showing 1 changed file with 38 additions and 35 deletions.
73 changes: 38 additions & 35 deletions lib/Dist/Zilla/Plugin/LocaleMsgfmt.pm
Original file line number Diff line number Diff line change
@@ -1,68 +1,49 @@
package Dist::Zilla::Plugin::LocaleMsgfmt;
# ABSTRACT: Dist::Zilla plugin that compiles Local::Msgfmt .po files to .mo files

=head1 DESCRIPTION
Put the following in your dist.ini
[LocaleMsgfmt]
locale = share/locale ;; (optional)
This plugin will compile all of the .po files it finds in the locale directory into .mo
files, via Locale::Msgfmt.
=head1 TODO
Remove the generated files after the build finishes, or better yet do the generation inside
the build dir.
=cut
# ABSTRACT: compiles .po files to .mo files with Local::Msgfmt

use Locale::Msgfmt 0.14;
use Moose;
with 'Dist::Zilla::Role::BeforeBuild';
use Path::Class;

=method mvp_multivalue_args
with 'Dist::Zilla::Role::BeforeBuild';

For Config::MVP - specify setting names that may have multiple values and that will always
be stored in an arrayref

=cut
# -- 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) }

=attr locale
Path to the directory containing the locale files.
=cut

has locale => (
is => 'ro',
isa => 'ArrayRef[Str]',
lazy => 1,
default => sub {
my ($self) = @_;
my $path = File::Spec->catfile( $self->zilla->root, 'share', 'locale' );
if ( -e $path ) {
return [$path];
}
else {
return [];
}
my $self = shift;
my $path = dir( $self->zilla->root, 'share', 'locale' );
return -e $path ? [ $path ] : [ ];
},
);

=method before_build

=cut
# -- public methods

#
# to implement Dist::Zilla::Role::BeforeBuild
sub before_build {
my ( $self, $args ) = @_;

for my $dir ( @{ $self->locale } ) {
my $path = Path::Class::Dir->new($dir);
my $path = dir($dir);
if ( -e $path ) {
$self->log("Generating .mo files from .po files in $path");
Locale::Msgfmt::msgfmt( { in => $path->absolute, verbose => 1, remove => 0 } );
msgfmt( { in => $path->absolute, verbose => 1, remove => 0 } );
}
else {
warn "Skipping invalid path: $path";
Expand All @@ -74,3 +55,25 @@ __PACKAGE__->meta->make_immutable;
no Moose;

1;
__END__
=for Pod::Coverage
before_build
mvp_multivalue_args
=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 TODO
Remove the generated files after the build finishes, or better yet do the generation inside
the build dir.

0 comments on commit 170f15f

Please sign in to comment.