~ubuntu-branches/ubuntu/jaunty/compiz/jaunty-updates

« back to all changes in this revision

Viewing changes to intltool-update

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2009-03-09 10:23:38 UTC
  • Revision ID: james.westby@ubuntu.com-20090309102338-w5iyzw2p2r2hptpi
Tags: 1:0.8.2-0ubuntu1
* new upstream release 0.8.2
  - dropped 070_revert_prop_change (upstream now)
  - dropped 071_fix_window_move (upstream now)
* debian/patches/033_compiz_manager_xdg_dirs:
  - fix compiz-wrapper when multiple compiz dirs are given
    (patch got dropped during the jaunty cycle) LP: #141621
* re-re-add /usr/share/gnome/wm-properties/compiz.desktop to
  make the gnome-window-properties work again (LP: #269805)
* debian/source_compiz.py, debian/rules:
  - include apport hook (LP: #338472)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/perl -w
2
 
# -*- Mode: perl; indent-tabs-mode: nil; c-basic-offset: 4  -*-
3
 
 
4
 
#
5
 
#  The Intltool Message Updater
6
 
#
7
 
#  Copyright (C) 2000-2003 Free Software Foundation.
8
 
#
9
 
#  Intltool is free software; you can redistribute it and/or
10
 
#  modify it under the terms of the GNU General Public License 
11
 
#  version 2 published by the Free Software Foundation.
12
 
#
13
 
#  Intltool is distributed in the hope that it will be useful,
14
 
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
 
#  General Public License for more details.
17
 
#
18
 
#  You should have received a copy of the GNU General Public License
19
 
#  along with this program; if not, write to the Free Software
20
 
#  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21
 
#
22
 
#  As a special exception to the GNU General Public License, if you
23
 
#  distribute this file as part of a program that contains a
24
 
#  configuration script generated by Autoconf, you may include it under
25
 
#  the same distribution terms that you use for the rest of that program.
26
 
#
27
 
#  Authors: Kenneth Christiansen <kenneth@gnu.org>
28
 
#           Maciej Stachowiak
29
 
#           Darin Adler <darin@bentspoon.com>
30
 
 
31
 
## Release information
32
 
my $PROGRAM = "intltool-update";
33
 
my $VERSION = "0.40.5";
34
 
my $PACKAGE = "intltool";
35
 
 
36
 
## Loaded modules
37
 
use strict;
38
 
use Getopt::Long;
39
 
use Cwd;
40
 
use File::Copy;
41
 
use File::Find;
42
 
 
43
 
## Scalars used by the option stuff
44
 
my $HELP_ARG       = 0;
45
 
my $VERSION_ARG    = 0;
46
 
my $DIST_ARG       = 0;
47
 
my $POT_ARG        = 0;
48
 
my $HEADERS_ARG    = 0;
49
 
my $MAINTAIN_ARG   = 0;
50
 
my $REPORT_ARG     = 0;
51
 
my $VERBOSE        = 0;
52
 
my $GETTEXT_PACKAGE = "";
53
 
my $OUTPUT_FILE    = "";
54
 
 
55
 
my @languages;
56
 
my %varhash = ();
57
 
my %po_files_by_lang = ();
58
 
 
59
 
# Regular expressions to categorize file types.
60
 
# FIXME: Please check if the following is correct
61
 
 
62
 
my $xml_support =
63
 
"xml(?:\\.in)*|".       # http://www.w3.org/XML/ (Note: .in is not required)
64
 
"ui|".                  # Bonobo specific - User Interface desc. files
65
 
"lang|".                # ?
66
 
"glade2?(?:\\.in)*|".   # Glade specific - User Interface desc. files (Note: .in is not required)
67
 
"scm(?:\\.in)*|".       # ? (Note: .in is not required)
68
 
"oaf(?:\\.in)+|".       # DEPRECATED: Replaces by Bonobo .server files 
69
 
"etspec|".              # ?
70
 
"server(?:\\.in)+|".    # Bonobo specific
71
 
"sheet(?:\\.in)+|".     # ?
72
 
"schemas(?:\\.in)+|".   # GConf specific
73
 
"pong(?:\\.in)+|".      # DEPRECATED: PONG is not used [by GNOME] any longer.
74
 
"kbd(?:\\.in)+|".       # GOK specific. 
75
 
"policy(?:\\.in)+";     # PolicyKit files
76
 
 
77
 
my $ini_support =
78
 
"icon(?:\\.in)+|".      # http://www.freedesktop.org/Standards/icon-theme-spec
79
 
"desktop(?:\\.in)+|".   # http://www.freedesktop.org/Standards/menu-spec
80
 
"caves(?:\\.in)+|".     # GNOME Games specific
81
 
"directory(?:\\.in)+|". # http://www.freedesktop.org/Standards/menu-spec
82
 
"soundlist(?:\\.in)+|". # GNOME specific
83
 
"keys(?:\\.in)+|".      # GNOME Mime database specific
84
 
"theme(?:\\.in)+|".     # http://www.freedesktop.org/Standards/icon-theme-spec
85
 
"service(?:\\.in)+";    # DBus specific
86
 
 
87
 
my $buildin_gettext_support = 
88
 
"c|y|cs|cc|cpp|c\\+\\+|h|hh|gob|py";
89
 
 
90
 
## Always flush buffer when printing
91
 
$| = 1;
92
 
 
93
 
## Sometimes the source tree will be rooted somewhere else.
94
 
my $SRCDIR = $ENV{"srcdir"} || ".";
95
 
my $POTFILES_in;
96
 
 
97
 
$POTFILES_in = "<$SRCDIR/POTFILES.in";
98
 
 
99
 
my $devnull = ($^O eq 'MSWin32' ? 'NUL:' : '/dev/null');
100
 
 
101
 
## Handle options
102
 
GetOptions 
103
 
(
104
 
 "help"                => \$HELP_ARG,
105
 
 "version"             => \$VERSION_ARG,
106
 
 "dist|d"              => \$DIST_ARG,
107
 
 "pot|p"               => \$POT_ARG,
108
 
 "headers|s"           => \$HEADERS_ARG,
109
 
 "maintain|m"          => \$MAINTAIN_ARG,
110
 
 "report|r"            => \$REPORT_ARG,
111
 
 "verbose|x"           => \$VERBOSE,
112
 
 "gettext-package|g=s" => \$GETTEXT_PACKAGE,
113
 
 "output-file|o=s"     => \$OUTPUT_FILE,
114
 
 ) or &Console_WriteError_InvalidOption;
115
 
 
116
 
&Console_Write_IntltoolHelp if $HELP_ARG;
117
 
&Console_Write_IntltoolVersion if $VERSION_ARG;
118
 
 
119
 
my $arg_count = ($DIST_ARG > 0)
120
 
    + ($POT_ARG > 0)
121
 
    + ($HEADERS_ARG > 0)
122
 
    + ($MAINTAIN_ARG > 0)
123
 
    + ($REPORT_ARG > 0);
124
 
 
125
 
&Console_Write_IntltoolHelp if $arg_count > 1;
126
 
 
127
 
my $MODULE = $GETTEXT_PACKAGE || FindPackageName() || "unknown";
128
 
 
129
 
if ($POT_ARG)
130
 
{
131
 
    &GenerateHeaders;
132
 
    &GeneratePOTemplate;
133
 
}
134
 
elsif ($HEADERS_ARG)
135
 
{
136
 
    &GenerateHeaders;
137
 
}
138
 
elsif ($MAINTAIN_ARG)
139
 
{
140
 
    &FindLeftoutFiles;
141
 
}
142
 
elsif ($REPORT_ARG)
143
 
{
144
 
    &GenerateHeaders;
145
 
    &GeneratePOTemplate;
146
 
    &Console_Write_CoverageReport;
147
 
}
148
 
elsif ((defined $ARGV[0]) && $ARGV[0] =~ /^[a-z]/)
149
 
{
150
 
    my $lang = $ARGV[0];
151
 
 
152
 
    ## Report error if the language file supplied
153
 
    ## to the command line is non-existent
154
 
    &Console_WriteError_NotExisting("$SRCDIR/$lang.po")
155
 
        if ! -s "$SRCDIR/$lang.po";
156
 
 
157
 
    if (!$DIST_ARG)
158
 
    {
159
 
        print "Working, please wait..." if $VERBOSE;
160
 
        &GenerateHeaders;
161
 
        &GeneratePOTemplate;
162
 
    }
163
 
    &POFile_Update ($lang, $OUTPUT_FILE);
164
 
    &Console_Write_TranslationStatus ($lang, $OUTPUT_FILE);
165
 
166
 
else 
167
 
{
168
 
    &Console_Write_IntltoolHelp;
169
 
}
170
 
 
171
 
exit;
172
 
 
173
 
#########
174
 
 
175
 
sub Console_Write_IntltoolVersion
176
 
{
177
 
    print <<_EOF_;
178
 
${PROGRAM} (${PACKAGE}) $VERSION
179
 
Written by Kenneth Christiansen, Maciej Stachowiak, and Darin Adler.
180
 
 
181
 
Copyright (C) 2000-2003 Free Software Foundation, Inc.
182
 
This is free software; see the source for copying conditions.  There is NO
183
 
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
184
 
_EOF_
185
 
    exit;
186
 
}
187
 
 
188
 
sub Console_Write_IntltoolHelp
189
 
{
190
 
    print <<_EOF_;
191
 
Usage: ${PROGRAM} [OPTION]... LANGCODE
192
 
Updates PO template files and merge them with the translations.
193
 
 
194
 
Mode of operation (only one is allowed):
195
 
  -p, --pot                   generate the PO template only
196
 
  -s, --headers               generate the header files in POTFILES.in
197
 
  -m, --maintain              search for left out files from POTFILES.in
198
 
  -r, --report                display a status report for the module
199
 
  -d, --dist                  merge LANGCODE.po with existing PO template
200
 
 
201
 
Extra options:
202
 
  -g, --gettext-package=NAME  override PO template name, useful with --pot
203
 
  -o, --output-file=FILE      write merged translation to FILE
204
 
  -x, --verbose               display lots of feedback
205
 
      --help                  display this help and exit
206
 
      --version               output version information and exit
207
 
 
208
 
Examples of use:
209
 
${PROGRAM} --pot    just create a new PO template
210
 
${PROGRAM} xy       create new PO template and merge xy.po with it
211
 
 
212
 
Report bugs to http://bugzilla.gnome.org/ (product name "$PACKAGE")
213
 
or send email to <xml-i18n-tools\@gnome.org>.
214
 
_EOF_
215
 
    exit;
216
 
}
217
 
 
218
 
sub echo_n
219
 
{
220
 
    my $str = shift;
221
 
    my $ret = `echo "$str"`;
222
 
 
223
 
    $ret =~ s/\n$//; # do we need the "s" flag?
224
 
 
225
 
    return $ret;
226
 
}
227
 
 
228
 
sub POFile_DetermineType ($) 
229
 
{
230
 
   my $type = $_;
231
 
   my $gettext_type;
232
 
 
233
 
   my $xml_regex     = "(?:" . $xml_support . ")";
234
 
   my $ini_regex     = "(?:" . $ini_support . ")";
235
 
   my $buildin_regex = "(?:" . $buildin_gettext_support . ")";
236
 
 
237
 
   if ($type =~ /\[type: gettext\/([^\]].*)]/) 
238
 
   {
239
 
        $gettext_type=$1;
240
 
   }
241
 
   elsif ($type =~ /schemas(\.in)+$/) 
242
 
   {
243
 
        $gettext_type="schemas";
244
 
   }
245
 
   elsif ($type =~ /glade2?(\.in)*$/) 
246
 
   {
247
 
       $gettext_type="glade";
248
 
   }
249
 
   elsif ($type =~ /scm(\.in)*$/) 
250
 
   {
251
 
       $gettext_type="scheme";
252
 
   }
253
 
   elsif ($type =~ /keys(\.in)+$/) 
254
 
   {
255
 
       $gettext_type="keys";
256
 
   }
257
 
 
258
 
   # bucket types
259
 
 
260
 
   elsif ($type =~ /$xml_regex$/) 
261
 
   {
262
 
       $gettext_type="xml";
263
 
   }
264
 
   elsif ($type =~ /$ini_regex$/) 
265
 
   { 
266
 
       $gettext_type="ini";
267
 
   }
268
 
   elsif ($type =~ /$buildin_regex$/) 
269
 
   {
270
 
       $gettext_type="buildin";
271
 
   }
272
 
   else
273
 
   { 
274
 
       $gettext_type="unknown"; 
275
 
   }
276
 
 
277
 
   return "gettext\/$gettext_type";
278
 
}
279
 
 
280
 
sub TextFile_DetermineEncoding ($) 
281
 
{
282
 
    my $gettext_code="UTF-8"; # All files are UTF-8 by default
283
 
    my $filetype=`file $_ | cut -d ' ' -f 2`;
284
 
 
285
 
    if ($? eq "0")
286
 
    {
287
 
        if ($filetype =~ /^(ISO|UTF)/)
288
 
        {
289
 
            chomp ($gettext_code = $filetype);
290
 
        }
291
 
        elsif ($filetype =~ /^XML/)
292
 
        {
293
 
            $gettext_code="UTF-8"; # We asume that .glade and other .xml files are UTF-8
294
 
        }
295
 
    }
296
 
 
297
 
    return $gettext_code;
298
 
}
299
 
 
300
 
sub isNotValidMissing
301
 
{
302
 
    my ($file) = @_;
303
 
 
304
 
    return if $file =~ /^\{arch\}\/.*$/;
305
 
    return if $file =~ /^$varhash{"PACKAGE"}-$varhash{"VERSION"}\/.*$/;
306
 
}
307
 
 
308
 
sub FindLeftoutFiles
309
 
{
310
 
    my (@buf_i18n_plain,
311
 
        @buf_i18n_xml,
312
 
        @buf_i18n_xml_unmarked,
313
 
        @buf_i18n_ini,
314
 
        @buf_potfiles,
315
 
        @buf_potfiles_ignore,
316
 
        @buf_allfiles,
317
 
        @buf_allfiles_sorted,
318
 
        @buf_potfiles_sorted,
319
 
        @buf_potfiles_ignore_sorted
320
 
    );
321
 
 
322
 
    ## Search and find all translatable files
323
 
    find sub { 
324
 
        push @buf_i18n_plain,        "$File::Find::name" if /\.($buildin_gettext_support)$/;
325
 
        push @buf_i18n_xml,          "$File::Find::name" if /\.($xml_support)$/;
326
 
        push @buf_i18n_ini,          "$File::Find::name" if /\.($ini_support)$/;
327
 
        push @buf_i18n_xml_unmarked, "$File::Find::name" if /\.(schemas(\.in)+)$/;
328
 
        }, "..";
329
 
    find sub { 
330
 
        push @buf_i18n_plain,        "$File::Find::name" if /\.($buildin_gettext_support)$/;
331
 
        push @buf_i18n_xml,          "$File::Find::name" if /\.($xml_support)$/;
332
 
        push @buf_i18n_ini,          "$File::Find::name" if /\.($ini_support)$/;
333
 
        push @buf_i18n_xml_unmarked, "$File::Find::name" if /\.(schemas(\.in)+)$/;
334
 
        }, "$SRCDIR/.." if "$SRCDIR" ne ".";
335
 
 
336
 
    open POTFILES, $POTFILES_in or die "$PROGRAM:  there's no POTFILES.in!\n";
337
 
    @buf_potfiles = grep !/^(#|\s*$)/, <POTFILES>;
338
 
    close POTFILES;
339
 
 
340
 
    foreach (@buf_potfiles) {
341
 
        s/^\[.*]\s*//;
342
 
    }
343
 
 
344
 
    print "Searching for missing translatable files...\n" if $VERBOSE;
345
 
 
346
 
    ## Check if we should ignore some found files, when
347
 
    ## comparing with POTFILES.in
348
 
    foreach my $ignore ("POTFILES.skip", "POTFILES.ignore")
349
 
    {
350
 
        (-s "$SRCDIR/$ignore") or next;
351
 
 
352
 
        if ("$ignore" eq "POTFILES.ignore")
353
 
        {
354
 
            print "The usage of POTFILES.ignore is deprecated. Please consider moving the\n".
355
 
                  "content of this file to POTFILES.skip.\n";
356
 
        }
357
 
 
358
 
        print "Found $ignore: Ignoring files...\n" if $VERBOSE;
359
 
        open FILE, "<$SRCDIR/$ignore" or die "ERROR: Failed to open $SRCDIR/$ignore!\n";
360
 
            
361
 
        while (<FILE>)
362
 
        {
363
 
            next if (/^$/);
364
 
            next if (/^(#|\s*$)/);
365
 
 
366
 
            my $skipdir = "../$_";
367
 
            $skipdir = "$SRCDIR/../$_" if "$SRCDIR" ne ".";
368
 
            $skipdir =~ s/\n//g;
369
 
 
370
 
            my @dirignored;
371
 
 
372
 
            if (-d "$skipdir")
373
 
            {
374
 
                find sub {
375
 
                    push @dirignored, "$File::Find::name" if /\.($buildin_gettext_support)$/;
376
 
                    push @dirignored, "$File::Find::name" if /\.($xml_support)$/;
377
 
                    push @dirignored, "$File::Find::name" if /\.($ini_support)$/;
378
 
                    push @dirignored, "$File::Find::name" if /\.(schemas(\.in)+)$/;
379
 
                }, "$skipdir";
380
 
                foreach my $ignored (@dirignored)
381
 
                {
382
 
                    $ignored =~ s/^$SRCDIR\///g;
383
 
                    $ignored =~ s/^..\///g;
384
 
                    $ignored =~ s/$/\n/g;
385
 
                    push @buf_potfiles_ignore, $ignored;
386
 
                }
387
 
                next;
388
 
            }
389
 
            push @buf_potfiles_ignore, $_;
390
 
        }
391
 
        close FILE;
392
 
 
393
 
        @buf_potfiles_ignore_sorted = sort (@buf_potfiles_ignore);
394
 
    }
395
 
 
396
 
    foreach my $file (@buf_i18n_plain)
397
 
    {
398
 
        my $in_comment = 0;
399
 
        my $in_macro = 0;
400
 
 
401
 
        open FILE, "<$file";
402
 
        while (<FILE>)
403
 
        {
404
 
            # Handle continued multi-line comment.
405
 
            if ($in_comment)
406
 
            {
407
 
                next unless s-.*\*/--;
408
 
                $in_comment = 0;
409
 
            }
410
 
 
411
 
            # Handle continued macro.
412
 
            if ($in_macro)
413
 
            {
414
 
                $in_macro = 0 unless /\\$/;
415
 
                next;
416
 
            }
417
 
 
418
 
            # Handle start of macro (or any preprocessor directive).
419
 
            if (/^\s*\#/)
420
 
            {
421
 
                $in_macro = 1 if /^([^\\]|\\.)*\\$/;
422
 
                next;
423
 
            }
424
 
 
425
 
            # Handle comments and quoted text.
426
 
            while (m-(/\*|//|\'|\")-) # \' and \" keep emacs perl mode happy
427
 
            {
428
 
                my $match = $1;
429
 
                if ($match eq "/*")
430
 
                {
431
 
                    if (!s-/\*.*?\*/--)
432
 
                    {
433
 
                        s-/\*.*--;
434
 
                        $in_comment = 1;
435
 
                    }
436
 
                }
437
 
                elsif ($match eq "//")
438
 
                {
439
 
                    s-//.*--;
440
 
                }
441
 
                else # ' or "
442
 
                {
443
 
                    if (!s-$match([^\\]|\\.)*?$match-QUOTEDTEXT-)
444
 
                    {
445
 
                        warn "mismatched quotes at line $. in $file\n";
446
 
                        s-$match.*--;
447
 
                    }
448
 
                }
449
 
            }       
450
 
 
451
 
            if (/\w\.GetString *\(QUOTEDTEXT/)
452
 
            {
453
 
                if (defined isNotValidMissing (unpack("x3 A*", $file))) {
454
 
                    ## Remove the first 3 chars and add newline
455
 
                    push @buf_allfiles, unpack("x3 A*", $file) . "\n";
456
 
                }
457
 
                last;
458
 
            }
459
 
 
460
 
            ## C_ N_ NC_ Q_ and _ are the macros defined in gi8n.h
461
 
            if (/(NC|[CNQ]?)_ *\(QUOTEDTEXT/)
462
 
            {
463
 
                if (defined isNotValidMissing (unpack("x3 A*", $file))) {
464
 
                    ## Remove the first 3 chars and add newline
465
 
                    push @buf_allfiles, unpack("x3 A*", $file) . "\n";
466
 
                }
467
 
                last;
468
 
            }
469
 
        }
470
 
        close FILE;
471
 
    }
472
 
 
473
 
    foreach my $file (@buf_i18n_xml) 
474
 
    {
475
 
        open FILE, "<$file";
476
 
        
477
 
        while (<FILE>) 
478
 
        {
479
 
            # FIXME: share the pattern matching code with intltool-extract
480
 
            if (/\s_[-A-Za-z0-9._:]+\s*=\s*\"([^"]+)\"/ || /<_[^>]+>/ || /translatable=\"yes\"/)
481
 
            {
482
 
                if (defined isNotValidMissing (unpack("x3 A*", $file))) {
483
 
                    push @buf_allfiles, unpack("x3 A*", $file) . "\n";
484
 
                }
485
 
                last;
486
 
            }
487
 
        }
488
 
        close FILE;
489
 
    }
490
 
 
491
 
    foreach my $file (@buf_i18n_ini)
492
 
    {
493
 
        open FILE, "<$file";
494
 
        while (<FILE>) 
495
 
        {
496
 
            if (/_(.*)=/)
497
 
            {
498
 
                if (defined isNotValidMissing (unpack("x3 A*", $file))) {
499
 
                    push @buf_allfiles, unpack("x3 A*", $file) . "\n";
500
 
                }
501
 
                last;
502
 
            }
503
 
        }
504
 
        close FILE;
505
 
    }
506
 
 
507
 
    foreach my $file (@buf_i18n_xml_unmarked)
508
 
    {
509
 
        if (defined isNotValidMissing (unpack("x3 A*", $file))) {
510
 
            push @buf_allfiles, unpack("x3 A*", $file) . "\n";
511
 
        }
512
 
    }
513
 
 
514
 
 
515
 
    @buf_allfiles_sorted = sort (@buf_allfiles);
516
 
    @buf_potfiles_sorted = sort (@buf_potfiles);
517
 
 
518
 
    my %in2;
519
 
    foreach (@buf_potfiles_sorted) 
520
 
    {
521
 
        s#^$SRCDIR/../##;
522
 
        s#^$SRCDIR/##;
523
 
        $in2{$_} = 1;
524
 
    }
525
 
 
526
 
    foreach (@buf_potfiles_ignore_sorted) 
527
 
    {
528
 
        s#^$SRCDIR/../##;
529
 
        s#^$SRCDIR/##;
530
 
        $in2{$_} = 1;
531
 
    }
532
 
 
533
 
    my @result;
534
 
 
535
 
    foreach (@buf_allfiles_sorted)
536
 
    {
537
 
        my $dummy = $_;
538
 
        my $srcdir = $SRCDIR;
539
 
 
540
 
        $srcdir =~ s#^../##;
541
 
        $dummy =~ s#^$srcdir/../##;
542
 
        $dummy =~ s#^$srcdir/##;
543
 
        $dummy =~ s#_build/##;
544
 
        if (!exists($in2{$dummy}))
545
 
        {
546
 
            push @result, $dummy
547
 
        }
548
 
    }
549
 
 
550
 
    my @buf_potfiles_notexist;
551
 
 
552
 
    foreach (@buf_potfiles_sorted)
553
 
    {
554
 
        chomp (my $dummy = $_);
555
 
        if ("$dummy" ne "" and !(-f "$SRCDIR/../$dummy" or -f "../$dummy"))
556
 
        {
557
 
            push @buf_potfiles_notexist, $_;
558
 
        }
559
 
    }
560
 
 
561
 
    ## Save file with information about the files missing
562
 
    ## if any, and give information about this procedure.
563
 
    if (@result + @buf_potfiles_notexist > 0)
564
 
    {
565
 
        if (@result) 
566
 
        {
567
 
            print "\n" if $VERBOSE;
568
 
            unlink "missing";
569
 
            open OUT, ">missing";
570
 
            print OUT @result;
571
 
            close OUT;
572
 
            warn "\e[1mThe following files contain translations and are currently not in use. Please\e[0m\n".
573
 
                 "\e[1mconsider adding these to the POTFILES.in file, located in the po/ directory.\e[0m\n\n";
574
 
            print STDERR @result, "\n";
575
 
            warn "If some of these files are left out on purpose then please add them to\n".
576
 
                 "POTFILES.skip instead of POTFILES.in. A file \e[1m'missing'\e[0m containing this list\n".
577
 
                 "of left out files has been written in the current directory.\n";
578
 
        }
579
 
        if (@buf_potfiles_notexist)
580
 
        {
581
 
            unlink "notexist";
582
 
            open OUT, ">notexist";
583
 
            print OUT @buf_potfiles_notexist;
584
 
            close OUT;
585
 
            warn "\n" if ($VERBOSE or @result);
586
 
            warn "\e[1mThe following files do not exist anymore:\e[0m\n\n";
587
 
            warn @buf_potfiles_notexist, "\n";
588
 
            warn "Please remove them from POTFILES.in. A file \e[1m'notexist'\e[0m\n".
589
 
                 "containing this list of absent files has been written in the current directory.\n";
590
 
        }
591
 
    }
592
 
 
593
 
    ## If there is nothing to complain about, notify the user
594
 
    else {
595
 
        print "\nAll files containing translations are present in POTFILES.in.\n" if $VERBOSE;
596
 
    }
597
 
}
598
 
 
599
 
sub Console_WriteError_InvalidOption
600
 
{
601
 
    ## Handle invalid arguments
602
 
    print STDERR "Try `${PROGRAM} --help' for more information.\n";
603
 
    exit 1;
604
 
}
605
 
 
606
 
sub isProgramInPath
607
 
{
608
 
    my ($file) = @_;
609
 
    # If either a file exists, or when run it returns 0 exit status
610
 
    return 1 if ((-x $file) or (system("$file --version >$devnull") == 0));
611
 
    return 0;
612
 
}
613
 
 
614
 
sub isGNUGettextTool
615
 
{
616
 
    my ($file) = @_;
617
 
    # Check that we are using GNU gettext tools
618
 
    if (isProgramInPath ($file))
619
 
    {
620
 
        my $version = `$file --version`;
621
 
        return 1 if ($version =~ m/.*\(GNU .*\).*/);
622
 
    }
623
 
    return 0;
624
 
}
625
 
 
626
 
sub GenerateHeaders
627
 
{
628
 
    my $EXTRACT = $ENV{"INTLTOOL_EXTRACT"} || "intltool-extract";
629
 
 
630
 
    $EXTRACT = "$^X $EXTRACT" if ($^O eq 'MSWin32' && !($EXTRACT =~ /perl/));
631
 
 
632
 
    ## Generate the .h header files, so we can allow glade and
633
 
    ## xml translation support
634
 
    if (! isProgramInPath ("$EXTRACT"))
635
 
    {
636
 
        print STDERR "\n *** The intltool-extract script wasn't found!"
637
 
             ."\n *** Without it, intltool-update can not generate files.\n";
638
 
        exit;
639
 
    }
640
 
    else
641
 
    {
642
 
        open (FILE, $POTFILES_in) or die "$PROGRAM: POTFILES.in not found.\n";
643
 
        
644
 
        while (<FILE>) 
645
 
        {
646
 
           chomp;
647
 
           next if /^\[\s*encoding/;
648
 
 
649
 
           ## Find xml files in POTFILES.in and generate the
650
 
           ## files with help from the extract script
651
 
 
652
 
           my $gettext_type= &POFile_DetermineType ($1);
653
 
 
654
 
           if (/\.($xml_support|$ini_support)$/ || /^\[/)
655
 
           {
656
 
               s/^\[[^\[].*]\s*//;
657
 
 
658
 
               my $filename = "../$_";
659
 
 
660
 
               if ($VERBOSE)
661
 
               {
662
 
                   system ($EXTRACT, "--update", "--srcdir=$SRCDIR",
663
 
                           "--type=$gettext_type", $filename);
664
 
               } 
665
 
               else 
666
 
               {
667
 
                   system ($EXTRACT, "--update", "--type=$gettext_type", 
668
 
                           "--srcdir=$SRCDIR", "--quiet", $filename);
669
 
               }
670
 
           }
671
 
       }
672
 
       close FILE;
673
 
   }
674
 
}
675
 
 
676
 
#
677
 
# Generate .pot file from POTFILES.in
678
 
#
679
 
sub GeneratePOTemplate
680
 
{
681
 
    my $XGETTEXT = $ENV{"XGETTEXT"} || "xgettext";
682
 
    my $XGETTEXT_ARGS = $ENV{"XGETTEXT_ARGS"} || '';
683
 
    chomp $XGETTEXT;
684
 
 
685
 
    if (! isGNUGettextTool ("$XGETTEXT"))
686
 
    {
687
 
        print STDERR " *** GNU xgettext is not found on this system!\n".
688
 
                     " *** Without it, intltool-update can not extract strings.\n";
689
 
        exit;
690
 
    }
691
 
 
692
 
    print "Building $MODULE.pot...\n" if $VERBOSE;
693
 
 
694
 
    open INFILE, $POTFILES_in;
695
 
    unlink "POTFILES.in.temp";
696
 
    open OUTFILE, ">POTFILES.in.temp" or die("Cannot open POTFILES.in.temp for writing");
697
 
 
698
 
    my $gettext_support_nonascii = 0;
699
 
 
700
 
    # checks for GNU gettext >= 0.12
701
 
    my $dummy = `$XGETTEXT --version --from-code=UTF-8 >$devnull 2>$devnull`;
702
 
    if ($? == 0)
703
 
    {
704
 
        $gettext_support_nonascii = 1;
705
 
    }
706
 
    else
707
 
    {
708
 
        # require gnu gettext >= 0.12
709
 
        die "$PROGRAM: GNU gettext >= 0.12 is required for intltool\n";
710
 
    }
711
 
 
712
 
    my $encoding = "UTF-8";
713
 
    my $forced_gettext_code;
714
 
    my @temp_headers;
715
 
    my $encoding_problem_is_reported = 0;
716
 
 
717
 
    while (<INFILE>) 
718
 
    {
719
 
        next if (/^#/ or /^\s*$/);
720
 
 
721
 
        chomp;
722
 
 
723
 
        my $gettext_code;
724
 
 
725
 
        if (/^\[\s*encoding:\s*(.*)\s*\]/)
726
 
        {
727
 
            $forced_gettext_code=$1;
728
 
        }
729
 
        elsif (/\.($xml_support|$ini_support)$/ || /^\[/)
730
 
        {
731
 
            s/^\[.*]\s*//;
732
 
            print OUTFILE "../$_.h\n";
733
 
            push @temp_headers, "../$_.h";
734
 
            $gettext_code = &TextFile_DetermineEncoding ("../$_.h") if ($gettext_support_nonascii and not defined $forced_gettext_code);
735
 
        } 
736
 
        else 
737
 
        {
738
 
            print OUTFILE "$SRCDIR/../$_\n";
739
 
            $gettext_code = &TextFile_DetermineEncoding ("$SRCDIR/../$_") if ($gettext_support_nonascii and not defined $forced_gettext_code);
740
 
        }
741
 
 
742
 
        next if (! $gettext_support_nonascii);
743
 
 
744
 
        if (defined $forced_gettext_code)
745
 
        {
746
 
            $encoding=$forced_gettext_code;
747
 
        }
748
 
        elsif (defined $gettext_code and "$encoding" ne "$gettext_code")
749
 
        {
750
 
            if ($encoding eq "ASCII")
751
 
            {
752
 
                $encoding=$gettext_code;
753
 
            }
754
 
            elsif ($gettext_code ne "ASCII")
755
 
            {
756
 
                # Only report once because the message is quite long
757
 
                if (! $encoding_problem_is_reported)
758
 
                {
759
 
                    print STDERR "WARNING: You should use the same file encoding for all your project files,\n".
760
 
                                 "         but $PROGRAM thinks that most of the source files are in\n".
761
 
                                 "         $encoding encoding, while \"$_\" is (likely) in\n".
762
 
                                 "         $gettext_code encoding. If you are sure that all translatable strings\n".
763
 
                                 "         are in same encoding (say UTF-8), please \e[1m*prepend*\e[0m the following\n".
764
 
                                 "         line to POTFILES.in:\n\n".
765
 
                                 "                 [encoding: UTF-8]\n\n".
766
 
                                 "         and make sure that configure.in/ac checks for $PACKAGE >= 0.27 .\n".
767
 
                                 "(such warning message will only be reported once.)\n";
768
 
                    $encoding_problem_is_reported = 1;
769
 
                }
770
 
            }
771
 
        }
772
 
    }
773
 
 
774
 
    close OUTFILE;
775
 
    close INFILE;
776
 
 
777
 
    unlink "$MODULE.pot";
778
 
    my @xgettext_argument=("$XGETTEXT",
779
 
                           "--add-comments",
780
 
                           "--directory\=.",
781
 
                           "--default-domain\=$MODULE",
782
 
                           "--flag\=g_strdup_printf:1:c-format",
783
 
                           "--flag\=g_string_printf:2:c-format",
784
 
                           "--flag\=g_string_append_printf:2:c-format",
785
 
                           "--flag\=g_error_new:3:c-format",
786
 
                           "--flag\=g_set_error:4:c-format",
787
 
                           "--flag\=g_markup_printf_escaped:1:c-format",
788
 
                           "--flag\=g_log:3:c-format",
789
 
                           "--flag\=g_print:1:c-format",
790
 
                           "--flag\=g_printerr:1:c-format",
791
 
                           "--flag\=g_printf:1:c-format",
792
 
                           "--flag\=g_fprintf:2:c-format",
793
 
                           "--flag\=g_sprintf:2:c-format",
794
 
                           "--flag\=g_snprintf:3:c-format",
795
 
                           "--flag\=g_scanner_error:2:c-format",
796
 
                           "--flag\=g_scanner_warn:2:c-format",
797
 
                           "--output\=$MODULE\.pot",
798
 
                           "--files-from\=\.\/POTFILES\.in\.temp");
799
 
    my $XGETTEXT_KEYWORDS = &FindPOTKeywords;
800
 
    push @xgettext_argument, $XGETTEXT_KEYWORDS;
801
 
    my $MSGID_BUGS_ADDRESS = &FindMakevarsBugAddress;
802
 
    push @xgettext_argument, "--msgid-bugs-address\=\"$MSGID_BUGS_ADDRESS\"" if $MSGID_BUGS_ADDRESS;
803
 
    push @xgettext_argument, "--from-code\=$encoding" if ($gettext_support_nonascii);
804
 
    push @xgettext_argument, $XGETTEXT_ARGS if $XGETTEXT_ARGS;
805
 
    my $xgettext_command = join ' ', @xgettext_argument;
806
 
 
807
 
    # intercept xgettext error message
808
 
    print "Running $xgettext_command\n" if $VERBOSE;
809
 
    my $xgettext_error_msg = `$xgettext_command 2>\&1`;
810
 
    my $command_failed = $?;
811
 
 
812
 
    unlink "POTFILES.in.temp";
813
 
 
814
 
    print "Removing generated header (.h) files..." if $VERBOSE;
815
 
    unlink foreach (@temp_headers);
816
 
    print "done.\n" if $VERBOSE;
817
 
 
818
 
    if (! $command_failed)
819
 
    {
820
 
        if (! -e "$MODULE.pot")
821
 
        {
822
 
            print "None of the files in POTFILES.in contain strings marked for translation.\n" if $VERBOSE;
823
 
        }
824
 
        else
825
 
        {
826
 
            print "Wrote $MODULE.pot\n" if $VERBOSE;
827
 
        }
828
 
    }
829
 
    else
830
 
    {
831
 
        if ($xgettext_error_msg =~ /--from-code/)
832
 
        {
833
 
            my $errlocation = "unknown";
834
 
 
835
 
            if ($xgettext_error_msg =~ /Non-ASCII string at (.*)\..*/)
836
 
            {
837
 
                $errlocation = $1;
838
 
            }
839
 
            print STDERR "ERROR: xgettext failed to generate PO tempalte file because the following     \n".
840
 
                         "       file contains strings marked for translation, not encoded in UTF-8.    \n".
841
 
                         "       Please ensure all strings marked for translation are UTF-8 encoded.  \n\n".
842
 
                         "           $errlocation\n\n";
843
 
        }
844
 
        else
845
 
        {
846
 
            print STDERR "$xgettext_error_msg";
847
 
            if (-e "$MODULE.pot")
848
 
            {
849
 
                # is this possible?
850
 
                print STDERR "ERROR: xgettext failed but still managed to generate PO template file.\n".
851
 
                             "       Please consult error message above if there is any.\n";
852
 
            }
853
 
            else
854
 
            {
855
 
                print STDERR "ERROR: xgettext failed to generate PO template file. Please consult\n".
856
 
                             "       error message above if there is any.\n";
857
 
            }
858
 
        }
859
 
        exit (1);
860
 
    }
861
 
}
862
 
 
863
 
sub POFile_Update
864
 
{
865
 
    -f "$MODULE.pot" or die "$PROGRAM: $MODULE.pot does not exist.\n";
866
 
 
867
 
    my $MSGMERGE = $ENV{"MSGMERGE"} || "msgmerge";
868
 
    my ($lang, $outfile) = @_;
869
 
 
870
 
    if (! isGNUGettextTool ("$MSGMERGE"))
871
 
    {
872
 
        print STDERR " *** GNU msgmerge is not found on this system!\n".
873
 
                     " *** Without it, intltool-update can not extract strings.\n";
874
 
        exit;
875
 
    }
876
 
 
877
 
    print "Merging $SRCDIR/$lang.po with $MODULE.pot..." if $VERBOSE;
878
 
 
879
 
    my $infile = "$SRCDIR/$lang.po";
880
 
    $outfile = "$SRCDIR/$lang.po" if ($outfile eq "");
881
 
 
882
 
    # I think msgmerge won't overwrite old file if merge is not successful
883
 
    system ("$MSGMERGE", "-o", $outfile, $infile, "$MODULE.pot");
884
 
}
885
 
 
886
 
sub Console_WriteError_NotExisting
887
 
{
888
 
    my ($file) = @_;
889
 
 
890
 
    ## Report error if supplied language file is non-existing
891
 
    print STDERR "$PROGRAM: $file does not exist!\n";
892
 
    print STDERR "Try '$PROGRAM --help' for more information.\n";
893
 
    exit;
894
 
}
895
 
 
896
 
sub GatherPOFiles
897
 
{
898
 
    my @po_files = glob ("./*.po");
899
 
 
900
 
    @languages = map (&POFile_GetLanguage, @po_files);
901
 
 
902
 
    foreach my $lang (@languages) 
903
 
    {
904
 
        $po_files_by_lang{$lang} = shift (@po_files);
905
 
    }
906
 
}
907
 
 
908
 
sub POFile_GetLanguage ($)
909
 
{
910
 
    s/^(.*\/)?(.+)\.po$/$2/;
911
 
    return $_;
912
 
}
913
 
 
914
 
sub Console_Write_TranslationStatus
915
 
{
916
 
    my ($lang, $output_file) = @_;
917
 
    my $MSGFMT = $ENV{"MSGFMT"} || "msgfmt";
918
 
 
919
 
    if (! isGNUGettextTool ("$MSGFMT"))
920
 
    {
921
 
        print STDERR " *** GNU msgfmt is not found on this system!\n".
922
 
                     " *** Without it, intltool-update can not extract strings.\n";
923
 
        exit;
924
 
    }
925
 
 
926
 
    $output_file = "$SRCDIR/$lang.po" if ($output_file eq "");
927
 
 
928
 
    system ("$MSGFMT", "-o", "$devnull", "--verbose", $output_file);
929
 
}
930
 
 
931
 
sub Console_Write_CoverageReport
932
 
{
933
 
    my $MSGFMT = $ENV{"MSGFMT"} || "msgfmt";
934
 
 
935
 
    if (! isGNUGettextTool ("$MSGFMT"))
936
 
    {
937
 
        print STDERR " *** GNU msgfmt is not found on this system!\n".
938
 
                     " *** Without it, intltool-update can not extract strings.\n";
939
 
        exit;
940
 
    }
941
 
 
942
 
    &GatherPOFiles;
943
 
 
944
 
    foreach my $lang (@languages) 
945
 
    {
946
 
        print STDERR "$lang: ";
947
 
        &POFile_Update ($lang, "");
948
 
    }
949
 
 
950
 
    print STDERR "\n\n * Current translation support in $MODULE \n\n";
951
 
 
952
 
    foreach my $lang (@languages)
953
 
    {
954
 
        print STDERR "$lang: ";
955
 
        system ("$MSGFMT", "-o", "$devnull", "--verbose", "$SRCDIR/$lang.po");
956
 
    }
957
 
}
958
 
 
959
 
sub SubstituteVariable
960
 
{
961
 
    my ($str) = @_;
962
 
    
963
 
    # always need to rewind file whenever it has been accessed
964
 
    seek (CONF, 0, 0);
965
 
 
966
 
    # cache each variable. varhash is global to we can add
967
 
    # variables elsewhere.
968
 
    while (<CONF>)
969
 
    {
970
 
        if (/^(\w+)=(.*)$/)
971
 
        {
972
 
            ($varhash{$1} = $2) =~  s/^["'](.*)["']$/$1/;
973
 
        }
974
 
    }
975
 
    
976
 
    if ($str =~ /^(.*)\${?([A-Z_]+)}?(.*)$/)
977
 
    {
978
 
        my $rest = $3;
979
 
        my $untouched = $1;
980
 
        my $sub = "";
981
 
        # Ignore recursive definitions of variables
982
 
        $sub = $varhash{$2} if defined $varhash{$2} and $varhash{$2} !~ /\${?$2}?/;
983
 
 
984
 
        return SubstituteVariable ("$untouched$sub$rest");
985
 
    }
986
 
    
987
 
    # We're using Perl backticks ` and "echo -n" here in order to 
988
 
    # expand any shell escapes (such as backticks themselves) in every variable
989
 
    return echo_n ($str);
990
 
}
991
 
 
992
 
sub CONF_Handle_Open
993
 
{
994
 
    my $base_dirname = getcwd();
995
 
    $base_dirname =~ s@.*/@@;
996
 
 
997
 
    my ($conf_in, $src_dir);
998
 
 
999
 
    if ($base_dirname =~ /^po(-.+)?$/) 
1000
 
    {
1001
 
        if (-f "Makevars") 
1002
 
        {
1003
 
            my $makefile_source;
1004
 
 
1005
 
            local (*IN);
1006
 
            open (IN, "<Makevars") || die "can't open Makevars: $!";
1007
 
 
1008
 
            while (<IN>) 
1009
 
            {
1010
 
                if (/^top_builddir[ \t]*=/) 
1011
 
                {
1012
 
                    $src_dir = $_;
1013
 
                    $src_dir =~ s/^top_builddir[ \t]*=[ \t]*([^ \t\n\r]*)/$1/;
1014
 
 
1015
 
                    chomp $src_dir;
1016
 
                    if (-f "$src_dir" . "/configure.ac") {
1017
 
                        $conf_in = "$src_dir" . "/configure.ac" . "\n";
1018
 
                    } else {
1019
 
                        $conf_in = "$src_dir" . "/configure.in" . "\n";
1020
 
                    }
1021
 
                    last;
1022
 
                }
1023
 
            }
1024
 
            close IN;
1025
 
 
1026
 
            $conf_in || die "Cannot find top_builddir in Makevars.";
1027
 
        }
1028
 
        elsif (-f "$SRCDIR/../configure.ac") 
1029
 
        {
1030
 
            $conf_in = "$SRCDIR/../configure.ac";
1031
 
        } 
1032
 
        elsif (-f "$SRCDIR/../configure.in") 
1033
 
        {
1034
 
            $conf_in = "$SRCDIR/../configure.in";
1035
 
        } 
1036
 
        else 
1037
 
        {
1038
 
            my $makefile_source;
1039
 
 
1040
 
            local (*IN);
1041
 
            open (IN, "<Makefile") || return;
1042
 
 
1043
 
            while (<IN>) 
1044
 
            {
1045
 
                if (/^top_srcdir[ \t]*=/) 
1046
 
                {
1047
 
                    $src_dir = $_;                  
1048
 
                    $src_dir =~ s/^top_srcdir[ \t]*=[ \t]*([^ \t\n\r]*)/$1/;
1049
 
 
1050
 
                    chomp $src_dir;
1051
 
                    $conf_in = "$src_dir" . "/configure.in" . "\n";
1052
 
 
1053
 
                    last;
1054
 
                }
1055
 
            }
1056
 
            close IN;
1057
 
 
1058
 
            $conf_in || die "Cannot find top_srcdir in Makefile.";
1059
 
        }
1060
 
 
1061
 
        open (CONF, "<$conf_in");
1062
 
    }
1063
 
    else
1064
 
    {
1065
 
        print STDERR "$PROGRAM: Unable to proceed.\n" .
1066
 
                     "Make sure to run this script inside the po directory.\n";
1067
 
        exit;
1068
 
    }
1069
 
}
1070
 
 
1071
 
sub FindPackageName
1072
 
{
1073
 
    my $version;
1074
 
    my $domain = &FindMakevarsDomain;
1075
 
    my $name = $domain || "untitled";
1076
 
 
1077
 
    &CONF_Handle_Open;
1078
 
 
1079
 
    my $conf_source; {
1080
 
        local (*IN);
1081
 
        open (IN, "<&CONF") || return $name;
1082
 
        seek (IN, 0, 0);
1083
 
        local $/; # slurp mode
1084
 
        $conf_source = <IN>;
1085
 
        close IN;
1086
 
    }
1087
 
 
1088
 
    # priority for getting package name:
1089
 
    # 1. GETTEXT_PACKAGE
1090
 
    # 2. first argument of AC_INIT (with >= 2 arguments)
1091
 
    # 3. first argument of AM_INIT_AUTOMAKE (with >= 2 argument)
1092
 
 
1093
 
    # /^AM_INIT_AUTOMAKE\([\s\[]*([^,\)\s\]]+)/m 
1094
 
    # the \s makes this not work, why?
1095
 
    if ($conf_source =~ /^AM_INIT_AUTOMAKE\(([^,\)]+),([^,\)]+)/m)
1096
 
    {
1097
 
        ($name, $version) = ($1, $2);
1098
 
        $name    =~ s/[\[\]\s]//g;
1099
 
        $version =~ s/[\[\]\s]//g;
1100
 
        $name    =~ s/\(+$//g;
1101
 
        $version =~ s/\(+$//g;
1102
 
 
1103
 
        $varhash{"PACKAGE_NAME"} = $name if (not $name =~ /\${?AC_PACKAGE_NAME}?/);
1104
 
        $varhash{"PACKAGE"} = $name if (not $name =~ /\${?PACKAGE}?/);
1105
 
        $varhash{"PACKAGE_VERSION"} = $version if (not $name =~ /\${?AC_PACKAGE_VERSION}?/);
1106
 
        $varhash{"VERSION"} = $version if (not $name =~ /\${?VERSION}?/);
1107
 
    }
1108
 
    
1109
 
    if ($conf_source =~ /^AC_INIT\(([^,\)]+),([^,\)]+)/m) 
1110
 
    {
1111
 
        ($name, $version) = ($1, $2);
1112
 
        $name    =~ s/[\[\]\s]//g;
1113
 
        $version =~ s/[\[\]\s]//g;
1114
 
        $name    =~ s/\(+$//g;
1115
 
        $version =~ s/\(+$//g;
1116
 
 
1117
 
        $varhash{"PACKAGE_NAME"} = $name if (not $name =~ /\${?AC_PACKAGE_NAME}?/);
1118
 
        $varhash{"PACKAGE"} = $name if (not $name =~ /\${?PACKAGE}?/);
1119
 
        $varhash{"PACKAGE_VERSION"} = $version if (not $name =~ /\${?AC_PACKAGE_VERSION}?/);
1120
 
        $varhash{"VERSION"} = $version if (not $name =~ /\${?VERSION}?/);
1121
 
    }
1122
 
 
1123
 
    # \s makes this not work, why?
1124
 
    $name = $1 if $conf_source =~ /^GETTEXT_PACKAGE=\[?([^\n\]]+)/m;
1125
 
    
1126
 
    # m4 macros AC_PACKAGE_NAME, AC_PACKAGE_VERSION etc. have same value
1127
 
    # as corresponding $PACKAGE_NAME, $PACKAGE_VERSION etc. shell variables.
1128
 
    $name =~ s/\bAC_PACKAGE_/\$PACKAGE_/g;
1129
 
 
1130
 
    $name = $domain if $domain;
1131
 
 
1132
 
    $name = SubstituteVariable ($name);
1133
 
    $name =~ s/^["'](.*)["']$/$1/;
1134
 
 
1135
 
    return $name if $name;
1136
 
}
1137
 
 
1138
 
 
1139
 
sub FindPOTKeywords
1140
 
{
1141
 
 
1142
 
    my $keywords = "--keyword=_ --keyword=N_ --keyword=C_:1c,2 --keyword=NC_:1c,2 --keyword=Q_";
1143
 
    my $varname = "XGETTEXT_OPTIONS";
1144
 
    my $make_source; {
1145
 
        local (*IN);
1146
 
        open (IN, "<Makevars") || (open(IN, "<Makefile.in.in") && ($varname = "XGETTEXT_KEYWORDS")) || return $keywords;
1147
 
        seek (IN, 0, 0);
1148
 
        local $/; # slurp mode
1149
 
        $make_source = <IN>;
1150
 
        close IN;
1151
 
    }
1152
 
 
1153
 
    # unwrap lines split with a trailing \
1154
 
    $make_source =~  s/\\ $ \n/ /mxg;
1155
 
    $keywords = $1 if $make_source =~ /^$varname[ ]*=\[?([^\n\]]+)/m;
1156
 
    
1157
 
    return $keywords;
1158
 
}
1159
 
 
1160
 
sub FindMakevarsDomain
1161
 
{
1162
 
 
1163
 
    my $domain = "";
1164
 
    my $makevars_source; { 
1165
 
        local (*IN);
1166
 
        open (IN, "<Makevars") || return $domain;
1167
 
        seek (IN, 0, 0);
1168
 
        local $/; # slurp mode
1169
 
        $makevars_source = <IN>;
1170
 
        close IN;
1171
 
    }
1172
 
 
1173
 
    $domain = $1 if $makevars_source =~ /^DOMAIN[ ]*=\[?([^\n\]\$]+)/m;
1174
 
    $domain =~ s/^\s+//;
1175
 
    $domain =~ s/\s+$//;
1176
 
    
1177
 
    return $domain;
1178
 
}
1179
 
 
1180
 
sub FindMakevarsBugAddress
1181
 
{
1182
 
 
1183
 
    my $address = "";
1184
 
    my $makevars_source; { 
1185
 
        local (*IN);
1186
 
        open (IN, "<Makevars") || return undef;
1187
 
        seek (IN, 0, 0);
1188
 
        local $/; # slurp mode
1189
 
        $makevars_source = <IN>;
1190
 
        close IN;
1191
 
    }
1192
 
 
1193
 
    $address = $1 if $makevars_source =~ /^MSGID_BUGS_ADDRESS[ ]*=\[?([^\n\]\$]+)/m;
1194
 
    $address =~ s/^\s+//;
1195
 
    $address =~ s/\s+$//;
1196
 
    
1197
 
    return $address;
1198
 
}