~ubuntu-branches/ubuntu/lucid/quick-lounge-applet/lucid

« back to all changes in this revision

Viewing changes to intltool-update.in

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Starr-Bochicchio
  • Date: 2008-09-22 18:01:12 UTC
  • mfrom: (1.1.5 upstream) (4.1.1 squeeze)
  • Revision ID: james.westby@ubuntu.com-20080922180112-itm81kn3p09gduel
Tags: 2.12.5-5ubuntu1
* Merge from Debian unstable, remaining changes (LP: #273345):
 - Build-depend on xorg-dev, fix FTBFS.
 - Update Maintainer field as per spec. 
* Rebuild needed for libgnome-desktop-2 -> libgnome-desktop-2-7 transition

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 
31
31
## Release information
32
32
my $PROGRAM = "intltool-update";
33
 
my $VERSION = "0.35.0";
 
33
my $VERSION = "0.36.2";
34
34
my $PACKAGE = "intltool";
35
35
 
36
36
## Loaded modules
71
71
"sheet(?:\\.in)+|".     # ?
72
72
"schemas(?:\\.in)+|".   # GConf specific
73
73
"pong(?:\\.in)+|".      # DEPRECATED: PONG is not used [by GNOME] any longer.
74
 
"kbd(?:\\.in)+";        # GOK specific. 
 
74
"kbd(?:\\.in)+|".       # GOK specific. 
 
75
"policy(?:\\.in)+";     # PolicyKit files
75
76
 
76
77
my $ini_support =
77
78
"icon(?:\\.in)+|".      # http://www.freedesktop.org/Standards/icon-theme-spec
90
91
$| = 1;
91
92
 
92
93
## Sometimes the source tree will be rooted somewhere else.
93
 
my $SRCDIR = ".";
 
94
my $SRCDIR = $ENV{"srcdir"} || ".";
94
95
my $POTFILES_in;
95
96
 
96
 
$SRCDIR = $ENV{"srcdir"} if $ENV{"srcdir"};
97
97
$POTFILES_in = "<$SRCDIR/POTFILES.in";
98
98
 
99
99
my $devnull = ($^O eq 'MSWin32' ? 'NUL:' : '/dev/null');
124
124
 
125
125
&Console_Write_IntltoolHelp if $arg_count > 1;
126
126
 
 
127
my $PKGNAME = FindPackageName ();
 
128
 
127
129
# --version and --help don't require a module name
128
 
my $MODULE = $GETTEXT_PACKAGE || &FindPackageName || "unknown";
 
130
my $MODULE = $GETTEXT_PACKAGE || $PKGNAME || "unknown";
129
131
 
130
132
if ($POT_ARG)
131
133
{
316
318
        @buf_potfiles_ignore,
317
319
        @buf_allfiles,
318
320
        @buf_allfiles_sorted,
319
 
        @buf_potfiles_sorted
 
321
        @buf_potfiles_sorted,
 
322
        @buf_potfiles_ignore_sorted
320
323
    );
321
324
 
322
325
    ## Search and find all translatable files
326
329
        push @buf_i18n_ini,          "$File::Find::name" if /\.($ini_support)$/;
327
330
        push @buf_i18n_xml_unmarked, "$File::Find::name" if /\.(schemas(\.in)+)$/;
328
331
        }, "..";
329
 
 
 
332
    find sub { 
 
333
        push @buf_i18n_plain,        "$File::Find::name" if /\.($buildin_gettext_support)$/;
 
334
        push @buf_i18n_xml,          "$File::Find::name" if /\.($xml_support)$/;
 
335
        push @buf_i18n_ini,          "$File::Find::name" if /\.($ini_support)$/;
 
336
        push @buf_i18n_xml_unmarked, "$File::Find::name" if /\.(schemas(\.in)+)$/;
 
337
        }, "$SRCDIR/..";
330
338
 
331
339
    open POTFILES, $POTFILES_in or die "$PROGRAM:  there's no POTFILES.in!\n";
332
340
    @buf_potfiles = grep !/^(#|\s*$)/, <POTFILES>;
342
350
    ## comparing with POTFILES.in
343
351
    foreach my $ignore ("POTFILES.skip", "POTFILES.ignore")
344
352
    {
345
 
        (-s $ignore) or next;
 
353
        (-s "$SRCDIR/$ignore") or next;
346
354
 
347
355
        if ("$ignore" eq "POTFILES.ignore")
348
356
        {
351
359
        }
352
360
 
353
361
        print "Found $ignore: Ignoring files...\n" if $VERBOSE;
354
 
        open FILE, "<$ignore" or die "ERROR: Failed to open $ignore!\n";
 
362
        open FILE, "<$SRCDIR/$ignore" or die "ERROR: Failed to open $SRCDIR/$ignore!\n";
355
363
            
356
364
        while (<FILE>)
357
365
        {
359
367
        }
360
368
        close FILE;
361
369
 
362
 
        @buf_potfiles = (@buf_potfiles_ignore, @buf_potfiles);
 
370
        @buf_potfiles_ignore_sorted = sort (@buf_potfiles_ignore);
363
371
    }
364
372
 
365
373
    foreach my $file (@buf_i18n_plain)
417
425
                }
418
426
            }       
419
427
 
420
 
            if (/\.GetString ?\(QUOTEDTEXT/)
 
428
            if (/\w\.GetString *\(QUOTEDTEXT/)
421
429
            {
422
430
                if (defined isNotValidMissing (unpack("x3 A*", $file))) {
423
431
                    ## Remove the first 3 chars and add newline
426
434
                last;
427
435
            }
428
436
 
429
 
            if (/_\(QUOTEDTEXT/)
 
437
            ## N_ Q_ and _ are the three macros defined in gi8n.h
 
438
            if (/[NQ]?_ *\(QUOTEDTEXT/)
430
439
            {
431
440
                if (defined isNotValidMissing (unpack("x3 A*", $file))) {
432
441
                    ## Remove the first 3 chars and add newline
486
495
    my %in2;
487
496
    foreach (@buf_potfiles_sorted) 
488
497
    {
 
498
        s#^$SRCDIR/../##;
 
499
        s#^$SRCDIR/##;
 
500
        $in2{$_} = 1;
 
501
    }
 
502
 
 
503
    foreach (@buf_potfiles_ignore_sorted) 
 
504
    {
 
505
        s#^$SRCDIR/../##;
 
506
        s#^$SRCDIR/##;
489
507
        $in2{$_} = 1;
490
508
    }
491
509
 
493
511
 
494
512
    foreach (@buf_allfiles_sorted)
495
513
    {
496
 
        if (!exists($in2{$_}))
 
514
        my $dummy = $_;
 
515
        my $srcdir = $SRCDIR;
 
516
 
 
517
        $srcdir =~ s#^../##;
 
518
        $dummy =~ s#^$srcdir/../##;
 
519
        $dummy =~ s#^$srcdir/##;
 
520
        $dummy =~ s#_build/##;
 
521
        if (!exists($in2{$dummy}))
497
522
        {
498
 
            push @result, $_
 
523
            push @result, $dummy
499
524
        }
500
525
    }
501
526
 
504
529
    foreach (@buf_potfiles_sorted)
505
530
    {
506
531
        chomp (my $dummy = $_);
507
 
        if ("$dummy" ne "" and ! -f "../$dummy")
 
532
        if ("$dummy" ne "" and !(-f "$SRCDIR/../$dummy" or -f "../$dummy"))
508
533
        {
509
534
            push @buf_potfiles_notexist, $_;
510
535
        }
537
562
            warn "\n" if ($VERBOSE or @result);
538
563
            warn "\e[1mThe following files do not exist anymore:\e[0m\n\n";
539
564
            warn @buf_potfiles_notexist, "\n";
540
 
            warn "Please remove them from POTFILES.in or POTFILES.skip. A file \e[1m'notexist'\e[0m\n".
 
565
            warn "Please remove them from POTFILES.in. A file \e[1m'notexist'\e[0m\n".
541
566
                 "containing this list of absent files has been written in the current directory.\n";
542
567
        }
543
568
    }
555
580
    exit 1;
556
581
}
557
582
 
 
583
sub isProgramInPath
 
584
{
 
585
    my ($file) = @_;
 
586
    # If either a file exists, or when run it returns 0 exit status
 
587
    return 1 if ((-x $file) or (system("$file --version >$devnull") == 0));
 
588
    return 0;
 
589
}
 
590
 
 
591
sub isGNUGettextTool
 
592
{
 
593
    my ($file) = @_;
 
594
    # Check that we are using GNU gettext tools
 
595
    if (isProgramInPath ($file))
 
596
    {
 
597
        my $version = `$file --version`;
 
598
        return 1 if ($version =~ m/.*\(GNU .*\).*/);
 
599
    }
 
600
    return 0;
 
601
}
 
602
 
558
603
sub GenerateHeaders
559
604
{
560
 
    my $EXTRACT = "@INTLTOOL_EXTRACT@";
561
 
    chomp $EXTRACT;
562
 
 
563
 
    $EXTRACT = $ENV{"INTLTOOL_EXTRACT"} if $ENV{"INTLTOOL_EXTRACT"};
 
605
    my $EXTRACT = $ENV{"INTLTOOL_EXTRACT"} || "intltool-extract";
564
606
 
565
607
    ## Generate the .h header files, so we can allow glade and
566
608
    ## xml translation support
567
 
    if (! -x "$EXTRACT")
 
609
    if (! isProgramInPath ("$EXTRACT"))
568
610
    {
569
611
        print STDERR "\n *** The intltool-extract script wasn't found!"
570
612
             ."\n *** Without it, intltool-update can not generate files.\n";
611
653
#
612
654
sub GeneratePOTemplate
613
655
{
614
 
    my $XGETTEXT = $ENV{"XGETTEXT"} || "@INTLTOOL_XGETTEXT@";
 
656
    my $XGETTEXT = $ENV{"XGETTEXT"} || "xgettext";
615
657
    my $XGETTEXT_ARGS = $ENV{"XGETTEXT_ARGS"} || '';
616
658
    chomp $XGETTEXT;
617
659
 
618
 
    if (! -x $XGETTEXT)
 
660
    if (! isGNUGettextTool ("$XGETTEXT"))
619
661
    {
620
 
        print STDERR " *** xgettext is not found on this system!\n".
 
662
        print STDERR " *** GNU xgettext is not found on this system!\n".
621
663
                     " *** Without it, intltool-update can not extract strings.\n";
622
664
        exit;
623
665
    }
671
713
        } 
672
714
        else 
673
715
        {
674
 
            if ($SRCDIR eq ".") {
675
 
                print OUTFILE "../$_\n";
676
 
            } else {
677
 
                print OUTFILE "$SRCDIR/../$_\n";
678
 
            }
679
 
            $gettext_code = &TextFile_DetermineEncoding ("../$_") if ($gettext_support_nonascii and not defined $forced_gettext_code);
 
716
            print OUTFILE "$SRCDIR/../$_\n";
 
717
            $gettext_code = &TextFile_DetermineEncoding ("$SRCDIR/../$_") if ($gettext_support_nonascii and not defined $forced_gettext_code);
680
718
        }
681
719
 
682
720
        next if (! $gettext_support_nonascii);
717
755
    unlink "$MODULE.pot";
718
756
    my @xgettext_argument=("$XGETTEXT",
719
757
                           "--add-comments",
720
 
                           "--directory\=\.",
 
758
                           "--directory\=.",
 
759
                           "--default-domain\=$MODULE",
 
760
                           "--flag\=g_strdup_printf:1:c-format",
 
761
                           "--flag\=g_string_printf:2:c-format",
 
762
                           "--flag\=g_string_append_printf:2:c-format",
 
763
                           "--flag\=g_error_new:3:c-format",
 
764
                           "--flag\=g_set_error:4:c-format",
 
765
                           "--flag\=g_markup_printf_escaped:1:c-format",
 
766
                           "--flag\=g_log:3:c-format",
 
767
                           "--flag\=g_print:1:c-format",
 
768
                           "--flag\=g_printerr:1:c-format",
 
769
                           "--flag\=g_printf:1:c-format",
 
770
                           "--flag\=g_fprintf:2:c-format",
 
771
                           "--flag\=g_sprintf:2:c-format",
 
772
                           "--flag\=g_snprintf:3:c-format",
 
773
                           "--flag\=g_scanner_error:2:c-format",
 
774
                           "--flag\=g_scanner_warn:2:c-format",
721
775
                           "--output\=$MODULE\.pot",
722
776
                           "--files-from\=\.\/POTFILES\.in\.temp");
723
777
    my $XGETTEXT_KEYWORDS = &FindPOTKeywords;
784
838
{
785
839
    -f "$MODULE.pot" or die "$PROGRAM: $MODULE.pot does not exist.\n";
786
840
 
787
 
    my $MSGMERGE = $ENV{"MSGMERGE"} || "@INTLTOOL_MSGMERGE@";
 
841
    my $MSGMERGE = $ENV{"MSGMERGE"} || "msgmerge";
788
842
    my ($lang, $outfile) = @_;
789
843
 
 
844
    if (! isGNUGettextTool ("$MSGMERGE"))
 
845
    {
 
846
        print STDERR " *** GNU msgmerge is not found on this system!\n".
 
847
                     " *** Without it, intltool-update can not extract strings.\n";
 
848
        exit;
 
849
    }
 
850
 
790
851
    print "Merging $SRCDIR/$lang.po with $MODULE.pot..." if $VERBOSE;
791
852
 
792
853
    my $infile = "$SRCDIR/$lang.po";
827
888
sub Console_Write_TranslationStatus
828
889
{
829
890
    my ($lang, $output_file) = @_;
830
 
    my $MSGFMT = $ENV{"MSGFMT"} || "@INTLTOOL_MSGFMT@";
 
891
    my $MSGFMT = $ENV{"MSGFMT"} || "msgfmt";
 
892
 
 
893
    if (! isGNUGettextTool ("$MSGFMT"))
 
894
    {
 
895
        print STDERR " *** GNU msgfmt is not found on this system!\n".
 
896
                     " *** Without it, intltool-update can not extract strings.\n";
 
897
        exit;
 
898
    }
831
899
 
832
900
    $output_file = "$SRCDIR/$lang.po" if ($output_file eq "");
833
901
 
836
904
 
837
905
sub Console_Write_CoverageReport
838
906
{
839
 
    my $MSGFMT = $ENV{"MSGFMT"} || "@INTLTOOL_MSGFMT@";
 
907
    my $MSGFMT = $ENV{"MSGFMT"} || "msgfmt";
 
908
 
 
909
    if (! isGNUGettextTool ("$MSGFMT"))
 
910
    {
 
911
        print STDERR " *** GNU msgfmt is not found on this system!\n".
 
912
                     " *** Without it, intltool-update can not extract strings.\n";
 
913
        exit;
 
914
    }
840
915
 
841
916
    &GatherPOFiles;
842
917
 
843
918
    foreach my $lang (@languages) 
844
919
    {
845
 
        print "$lang: ";
 
920
        print STDERR "$lang: ";
846
921
        &POFile_Update ($lang, "");
847
922
    }
848
923
 
849
 
    print "\n\n * Current translation support in $MODULE \n\n";
 
924
    print STDERR "\n\n * Current translation support in $MODULE \n\n";
850
925
 
851
926
    foreach my $lang (@languages)
852
927
    {
853
 
        print "$lang: ";
 
928
        print STDERR "$lang: ";
854
929
        system ("$MSGFMT", "-o", "$devnull", "--verbose", "$SRCDIR/$lang.po");
855
930
    }
856
931
}
924
999
 
925
1000
            $conf_in || die "Cannot find top_builddir in Makevars.";
926
1001
        }
927
 
        elsif (-f "../configure.ac") 
 
1002
        elsif (-f "$SRCDIR/../configure.ac") 
928
1003
        {
929
 
            $conf_in = "../configure.ac";
 
1004
            $conf_in = "$SRCDIR/../configure.ac";
930
1005
        } 
931
 
        elsif (-f "../configure.in") 
 
1006
        elsif (-f "$SRCDIR/../configure.in") 
932
1007
        {
933
 
            $conf_in = "../configure.in";
 
1008
            $conf_in = "$SRCDIR/../configure.in";
934
1009
        } 
935
1010
        else 
936
1011
        {