/usr/bin/intltool-prepare is in intltool 0.50.2-2.
This file is owned by root:root, with mode 0o755.
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 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 | #!/usr/bin/perl -w
# -*- Mode: perl; indent-tabs-mode: nil; c-basic-offset: 4 -*-
# Intltool .desktop, .directory Prepare Tool
#
# Copyright (C) 2001 Free Software Foundation.
#
# Intltool is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# Intltool is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# Author(s): Gediminas Paulauskas <menesis@delfi.lt>
# Kenneth Christiansen <kenneth@gnu.org>
## Release information
my $PROGRAM = "intltool-prepare";
my $PACKAGE = "intltool";
my $VERSION = "0.50.2";
## Loaded modules
use strict;
use Getopt::Long;
use File::Find;
## Scalars used by the option stuff
my $HELP_ARG = "0";
my $VERSION_ARG = "0";
my $VERBOSE = "0";
my @languages;
my @desktop_files;
my $new;
my $file;
my $desktop_extension = "(desktop|soundlist|keys|directory)";
my $keywords = "Name|Comment|GenericName|SwallowTitle|description";
## Always print as the first thing
$| = 1;
## Handle options
GetOptions (
"help|h" => \$HELP_ARG,
"version|v" => \$VERSION_ARG,
"verbose|x" => \$VERBOSE
) or &invalid_option;
## Use the supplied arguments
## Check for options.
## This section will check for the different options.
sub split_on_argument {
if ($VERSION_ARG) {
&version;
} elsif ($HELP_ARG) {
&help;
} else {
&main;
}
}
&split_on_argument;
sub main
{
print "Working, please wait...\n" if (! $VERBOSE);
&find_desktop_files;
&append_keywords;
&add_to_potfiles;
&perform_rescue;
&add_to_cvsignore;
&fix_makefiles;
&generate_empty;
}
sub version {
print <<_EOF_;
${PROGRAM} ${PACKAGE} $VERSION
Written by Gediminas Paulauskas <menesis\@delfi.lt>, 2000.
Copyright (C) 2000 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
_EOF_
exit;
}
sub help
{
print <<_EOF_;
Usage: ${PROGRAM} [OPTION] KEYWORD...
Automates preparation steps before software make use of intltool.
KEYWORD is a list of additional key other than "Name", "Comment"
and "description".
-h, --help shows this help page
-v, --version shows the version
-x, --verbose show lots of feedback
Report bugs to http://bugs.launchpad.net/intltool
_EOF_
exit;
}
sub invalid_option
{
## Handle invalid arguments
## my $opt = $ARGV[0];
## print "$PROGRAM: invalid option -- $opt\n";
print STDERR "Try `$PROGRAM --help' for more information.\n";
exit 1;
}
sub append_keywords
{
my $arg;
foreach $arg (@ARGV) {
$keywords .= "|$arg";
}
}
sub add_to_potfiles
{
open FILE, ">>po/POTFILES.in";
my $intro = 0;
foreach my $desktop (@desktop_files) {
next if contains("po/POTFILES.in", "$desktop.in");
# Print explanation comment only once
unless ($intro) {
print FILE "# files added by intltool-prepare\n";
$intro = 1;
}
print FILE "$desktop.in\n";
}
close FILE;
}
sub perform_rescue
{
foreach $file (@desktop_files) {
&rescue_file($file);
}
}
sub rescue_file
{
my ($filename) = @_;
my ($msgid, $line, $lang);
print "Rescuing translations from $filename ...\n" if $VERBOSE;
open ORIG, "<$filename";
$line = 1;
ENTRY: while (<ORIG>) {
chomp;
$line++;
my $entry = $_;
if (($entry =~ /^($keywords)=(.*)$/) ||
($entry =~ /^(\s*description)=(.*)$/)) {
$msgid = $2;
$msgid =~ s/\\/\\\\/g;
$msgid =~ s/\"/\\"/g;
} elsif (($entry =~ /^($keywords)\[(.*?)\]=(.*)$/) ||
($entry =~ /^(\s*\[)(.*?)\]description=(.*)$/)) {
$lang = $2;
my $msgstr = $3;
$msgstr =~ s/\\/\\\\/g;
$msgstr =~ s/"/\\"/g;
$line--;
if ((-s "po/$lang.po") &&
(contains("po/$lang.po", "msgid \"$msgid\""))) {
next ENTRY;
}
open POFILE, ">>po/$lang.po";
print POFILE "\n#: $filename.in:$line\n";
print POFILE "msgid \"$msgid\"\n";
print POFILE "msgstr \"$msgstr\"\n";
close POFILE;
}
}
}
sub generate_empty
{
my $all = ' ';
foreach my $full (@desktop_files) {
$new = "$full.in";
$all .= "$new ";
print "Generating empty $new ...\n" if $VERBOSE;
open FULL, "<$full";
open NEW, ">$new";
while (<FULL>) {
unless (
(/^($keywords)\[.*?\]=.*$/) ||
(/^\s*\[(.*?)\]description=.*$/)
) {
if (/^($keywords)=.*$/) {
print NEW "_$_";
} elsif (/^(\s*)(description=.*)$/) {
print NEW "$1_$2\n";
} else {
print NEW;
}
}
}
close NEW;
}
unless ($all eq ' ') {
print "*** Please add these files to CVS by following command: ***\n"
. "cvs add$all\n";
}
}
sub add_to_cvsignore
{
my $all = ' ';
my $ign;
foreach $file (@desktop_files) {
$file =~ /^(.*\/)?(.+?\.$desktop_extension$)$/;
if ($1) {
$ign = "$1.cvsignore";
} else {
$ign = ".cvsignore";
}
my $basename = $2;
next if contains($ign, $basename);
print "Appending $basename to $ign\n" if $VERBOSE;
open FILE, ">>$ign";
print FILE "$basename\n";
$all .= "$file ";
}
close FILE;
unless ($all eq ' ') {
print "*** Please remove files from CVS by following command: ***\n"
. "cvs remove -f$all\n";
}
}
sub fix_makefiles
{
my $file;
foreach $file (@desktop_files) {
my ($makefile, $line);
$file =~ /^(.*\/)?(.+?\.$desktop_extension$)$/;
if ($1) {
$makefile = "$1Makefile.am";
} else {
$makefile = "Makefile.am";
}
my $basename = $2;
print "Fixing $basename entry in $makefile\n" if $VERBOSE;
open MAKE, $makefile;
open NEWMAKE, ">$makefile.new";
my $extra = 0;
while ($line = <MAKE>) {
$extra = 1 if $line =~ /^EXTRA_DIST/;
if ($extra) {
if (($line =~ /$basename/) &&
!($line =~ /$basename\.in/)) {
$line =~ s/$basename/$basename\.in/;
}
$extra = 0 unless $line =~ /\\\s*$/
} else {
if ($line =~ /^(\w+)_DATA\s*=\s*$basename\s*$/) {
my $name = $1;
$line =~ s/^$name\_DATA/$name\_in_files/;
$line =~ s/$basename/$basename\.in/;
$basename =~ /\.($desktop_extension)$/;
my $ext = $1;
$line .= "$name\_DATA = \$($name\_in_files:.$ext.in=.$ext)\n";
$ext =~ tr/a-z/A-Z/;
if (!contains($makefile, "\@INTLTOOL_$ext\_RULE\@")) {
$line .= "\@INTLTOOL_$ext\_RULE\@\n";
}
}
}
print NEWMAKE $line;
}
close NEWMAKE;
rename "$makefile.new", $makefile;
}
}
sub contains
{
my ($name, $str) = @_;
open CONT, "<$name";
while (<CONT>) {
chomp;
return 1 if $_ eq $str;
}
return 0;
}
sub find_desktop_files
{
if ($VERBOSE) {
print "Found these interesting files:\n";
} else {
print "Finding interesting files...";
}
find (\&wanted, '.');
print "done\n" unless $VERBOSE;
}
sub wanted
{
if (/\.$desktop_extension$/) {
my $file = $File::Find::name;
$file =~ s/\.\///;
push @desktop_files, $file;
print "$file\n" if $VERBOSE;
}
}
# vim: ts=4 sw=4 expandtab
|