This file is indexed.

/usr/share/perl5/Locale/Msgfmt.pm is in liblocale-msgfmt-perl 0.14-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
package Locale::Msgfmt;

use Locale::Msgfmt::mo;
use Locale::Msgfmt::po;
use Locale::Msgfmt::Utils;
use File::Path;
use File::Spec;

use strict;
use warnings;

use base 'Exporter';

our @EXPORT = qw/msgfmt/;

our $VERSION = '0.14';

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

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

sub _msgfmt {
	my $hash = shift;
	if ( !defined( $hash->{in} ) ) {
		die("error: must give an input file");
	}
	if ( !-f $hash->{in} ) {
		die("error: input file does not exist");
	}
	if ( !defined( $hash->{out} ) ) {
		if ( $hash->{in} =~ /\.po$/ ) {
			$hash->{out} = $hash->{in};
			$hash->{out} =~ s/po$/mo/;
		} else {
			die("error: must give an output file");
		}
	}
	unless ( $hash->{force} ) {
		return
			if ( -f $hash->{out}
			&& Locale::Msgfmt::Utils::mtime( $hash->{out} ) > Locale::Msgfmt::Utils::mtime( $hash->{in} ) );
	}
	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;
	if ( !-d $hash->{in} ) {
		die("error: input directory does not exist");
	}
	if ( !defined( $hash->{out} ) ) {
		$hash->{out} = $hash->{in};
	}
	if ( !-d $hash->{out} ) {
		File::Path::mkpath( $hash->{out} );
	}
	print $hash->{in} . " -> " . $hash->{out} . "\n" if ( $hash->{verbose} );
	opendir my $D, $hash->{in} or die "Could not open ($hash->{in}) $!";
	my @list = readdir $D;
	closedir $D;
	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 ) {
		my %newhash = ( %{$hash} );
		$newhash{in}  = $_;
		$newhash{out} = $files{$_};
		_msgfmt( \%newhash );
	}
	foreach (@removelist) {
		my $f = File::Spec->catfile( $hash->{in}, $_ );
		print "-$f\n" if ( $hash->{verbose} );
		unlink($f);
	}
}

1;

=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