This file is indexed.

/usr/share/perl5/Locale/Msgfmt.pm is in liblocale-msgfmt-perl 0.15-1.

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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
package Locale::Msgfmt;

use 5.008005;
use strict;
use warnings;
use Exporter              ();
use File::Spec            ();
use Locale::Msgfmt::mo    ();
use Locale::Msgfmt::po    ();
use Locale::Msgfmt::Utils ();

our $VERSION = '0.15';
our @ISA     = 'Exporter';
our @EXPORT  = qw/msgfmt/;

sub do_msgfmt_for_module_install {
	my $lib       = shift;
	my $sharepath = shift;
	my $fullpath  = File::Spec->catfile( $lib, $sharepath, 'locale' );
	unless ( -d $fullpath ) {
		die "$fullpath isn't a directory";
	}
	msgfmt( { in => $fullpath, verbose => 1, remove => 1 } );
}

sub msgfmt {
	my $hash = shift;
	unless ( defined($hash) ) {
		die "error: must give input";
	}
	unless ( ref($hash) eq "HASH" ) {
		$hash = { in => $hash };
	}
	unless ( defined $hash->{in} and length $hash->{in} ) {
		die "error: must give an input file";
	}
	unless ( -e $hash->{in} ) {
		die "error: input does not exist";
	}
	unless ( defined $hash->{verbose} ) {
		$hash->{verbose} = 1;
	}
	if ( -d $hash->{in} ) {
		return _msgfmt_dir($hash);
	} else {
		return _msgfmt($hash);
	}
}

sub _msgfmt {
	my $hash = shift;
	unless ( defined $hash->{in} ) {
		die "error: must give an input file";
	}
	unless ( -f $hash->{in} ) {
		die "error: input file does not exist";
	}
	unless ( defined $hash->{out} ) {
		unless ( $hash->{in} =~ /\.po$/ ) {
			die "error: must give an output file";
		}
		$hash->{out} = $hash->{in};
		$hash->{out} =~ s/po$/mo/;
	}
	unless ( $hash->{force} ) {
		my $min  = Locale::Msgfmt::Utils::mtime( $hash->{in} );
		my $mout = Locale::Msgfmt::Utils::mtime( $hash->{out} );
		if ( -f $hash->{out} and $mout > $min ) {
			return;
		}
	}
	my $mo = Locale::Msgfmt::mo->new;
	$mo->initialize;
	my $po = Locale::Msgfmt::po->new( { fuzzy => $hash->{fuzzy} } );
	$po->parse( $hash->{in}, $mo );
	$mo->prepare;
	unlink( $hash->{out} ) if -f $hash->{out};
	$mo->out( $hash->{out} );
	print $hash->{in} . " -> " . $hash->{out} . "\n" if $hash->{verbose};
	unlink( $hash->{in} ) if $hash->{remove};
}

sub _msgfmt_dir {
	my $hash = shift;
	unless ( -d $hash->{in} ) {
		die("error: input directory does not exist");
	}
	unless ( defined $hash->{out} ) {
		$hash->{out} = $hash->{in};
	}
	unless ( -d $hash->{out} ) {
		File::Path::mkpath( $hash->{out} );
	}

	print "$hash->{in} -> $hash->{out}\n" if $hash->{verbose};

	local *DIRECTORY;
	opendir( DIRECTORY, $hash->{in} ) or die "Could not open ($hash->{in}) $!";
	my @list = readdir DIRECTORY;
	closedir DIRECTORY;

	my @removelist = ();
	if ( $hash->{remove} ) {
		@removelist = grep /\.pot$/, @list;
	}
	@list = grep /\.po$/, @list;

	my %files;
	foreach ( @list ) {
		my $in  = File::Spec->catfile( $hash->{in}, $_ );
		my $out = File::Spec->catfile( $hash->{out}, substr( $_, 0, -3 ) . ".mo" );
		$files{$in} = $out;
	}
	foreach ( keys %files ) {
		_msgfmt( { %$hash, in  => $_, out => $files{$_} } );
	}
	foreach ( @removelist ) {
		my $f = File::Spec->catfile( $hash->{in}, $_ );
		print "-$f\n" if $hash->{verbose};
		unlink($f);
	}
}

1;

=pod

=head1 NAME

Locale::Msgfmt - Compile .po files to .mo files

=head1 SYNOPSIS

This module does the same thing as msgfmt from GNU gettext-tools,
except this is pure Perl. The interface is best explained through
examples:

  use Locale::Msgfmt;

  # Compile po/fr.po into po/fr.mo
  msgfmt({in => "po/fr.po", out => "po/fr.mo"});
  
  # Compile po/fr.po into po/fr.mo and include fuzzy translations
  msgfmt({in => "po/fr.po", out => "po/fr.mo", fuzzy => 1});
  
  # Compile all the .po files in the po directory, and write the .mo
  # files to the po directory
  msgfmt("po/");
  
  # Compile all the .po files in the po directory, and write the .mo
  # files to the po directory, and include fuzzy translations
  msgfmt({in => "po/", fuzzy => 1});
  
  # Compile all the .po files in the po directory, and write the .mo
  # files to the output directory, creating the output directory if
  # it doesn't already exist
  msgfmt({in => "po/", out => "output/"});
  
  # Compile all the .po files in the po directory, and write the .mo
  # files to the output directory, and include fuzzy translations
  msgfmt({in => "po/", out => "output/", fuzzy => 1});
  
  # Compile po/fr.po into po/fr.mo
  msgfmt("po/fr.po");
  
  # Compile po/fr.po into po/fr.mo and include fuzzy translations
  msgfmt({in => "po/fr.po", fuzzy => 1});

=head1 COPYRIGHT & LICENSE

Copyright 2009 Ryan Niebur, all rights reserved.

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.

=cut