~ubuntu-branches/ubuntu/gutsy/serpentine/gutsy

« back to all changes in this revision

Viewing changes to intltool-update.in

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2007-08-16 21:15:55 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070816211555-t0h0nugk2kn1tb61
Tags: 0.9-0ubuntu1
* New upstream version
* debian/control:
  - updated XS-Python-Version value

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.34.1";
 
33
my $VERSION = "0.35.5";
34
34
my $PACKAGE = "intltool";
35
35
 
36
36
## Loaded modules
80
80
"directory(?:\\.in)+|". # http://www.freedesktop.org/Standards/menu-spec
81
81
"soundlist(?:\\.in)+|". # GNOME specific
82
82
"keys(?:\\.in)+|".      # GNOME Mime database specific
83
 
"theme(?:\\.in)+";      # http://www.freedesktop.org/Standards/icon-theme-spec
 
83
"theme(?:\\.in)+|".     # http://www.freedesktop.org/Standards/icon-theme-spec
 
84
"service(?:\\.in)+";    # DBus specific
84
85
 
85
86
my $buildin_gettext_support = 
86
87
"c|y|cs|cc|cpp|c\\+\\+|h|hh|gob|py";
89
90
$| = 1;
90
91
 
91
92
## Sometimes the source tree will be rooted somewhere else.
92
 
my $SRCDIR = ".";
 
93
my $SRCDIR = $ENV{"srcdir"} || ".";
93
94
my $POTFILES_in;
94
95
 
95
 
$SRCDIR = $ENV{"srcdir"} if $ENV{"srcdir"};
96
96
$POTFILES_in = "<$SRCDIR/POTFILES.in";
97
97
 
98
98
my $devnull = ($^O eq 'MSWin32' ? 'NUL:' : '/dev/null');
123
123
 
124
124
&Console_Write_IntltoolHelp if $arg_count > 1;
125
125
 
 
126
my $PKGNAME = FindPackageName ();
 
127
 
126
128
# --version and --help don't require a module name
127
 
my $MODULE = $GETTEXT_PACKAGE || &FindPackageName;
 
129
my $MODULE = $GETTEXT_PACKAGE || $PKGNAME || "unknown";
128
130
 
129
131
if ($POT_ARG)
130
132
{
315
317
        @buf_potfiles_ignore,
316
318
        @buf_allfiles,
317
319
        @buf_allfiles_sorted,
318
 
        @buf_potfiles_sorted
 
320
        @buf_potfiles_sorted,
 
321
        @buf_potfiles_ignore_sorted
319
322
    );
320
323
 
321
324
    ## Search and find all translatable files
341
344
    ## comparing with POTFILES.in
342
345
    foreach my $ignore ("POTFILES.skip", "POTFILES.ignore")
343
346
    {
344
 
        (-s $ignore) or next;
 
347
        (-s "$SRCDIR/$ignore") or next;
345
348
 
346
349
        if ("$ignore" eq "POTFILES.ignore")
347
350
        {
350
353
        }
351
354
 
352
355
        print "Found $ignore: Ignoring files...\n" if $VERBOSE;
353
 
        open FILE, "<$ignore" or die "ERROR: Failed to open $ignore!\n";
 
356
        open FILE, "<$SRCDIR/$ignore" or die "ERROR: Failed to open $SRCDIR/$ignore!\n";
354
357
            
355
358
        while (<FILE>)
356
359
        {
358
361
        }
359
362
        close FILE;
360
363
 
361
 
        @buf_potfiles = (@buf_potfiles_ignore, @buf_potfiles);
 
364
        @buf_potfiles_ignore_sorted = sort (@buf_potfiles_ignore);
362
365
    }
363
366
 
364
367
    foreach my $file (@buf_i18n_plain)
416
419
                }
417
420
            }       
418
421
 
419
 
            if (/\.GetString ?\(QUOTEDTEXT/)
 
422
            if (/\w\.GetString *\(QUOTEDTEXT/)
420
423
            {
421
424
                if (defined isNotValidMissing (unpack("x3 A*", $file))) {
422
425
                    ## Remove the first 3 chars and add newline
425
428
                last;
426
429
            }
427
430
 
428
 
            if (/_\(QUOTEDTEXT/)
 
431
            ## N_ Q_ and _ are the three macros defined in gi8n.h
 
432
            if (/[NQ]?_ *\(QUOTEDTEXT/)
429
433
            {
430
434
                if (defined isNotValidMissing (unpack("x3 A*", $file))) {
431
435
                    ## Remove the first 3 chars and add newline
488
492
        $in2{$_} = 1;
489
493
    }
490
494
 
 
495
    foreach (@buf_potfiles_ignore_sorted) 
 
496
    {
 
497
        $in2{$_} = 1;
 
498
    }
 
499
 
491
500
    my @result;
492
501
 
493
502
    foreach (@buf_allfiles_sorted)
503
512
    foreach (@buf_potfiles_sorted)
504
513
    {
505
514
        chomp (my $dummy = $_);
506
 
        if ("$dummy" ne "" and ! -f "../$dummy")
 
515
        if ("$dummy" ne "" and !(-f "$SRCDIR/../$dummy" or -f "../$dummy"))
507
516
        {
508
517
            push @buf_potfiles_notexist, $_;
509
518
        }
536
545
            warn "\n" if ($VERBOSE or @result);
537
546
            warn "\e[1mThe following files do not exist anymore:\e[0m\n\n";
538
547
            warn @buf_potfiles_notexist, "\n";
539
 
            warn "Please remove them from POTFILES.in or POTFILES.skip. A file \e[1m'notexist'\e[0m\n".
 
548
            warn "Please remove them from POTFILES.in. A file \e[1m'notexist'\e[0m\n".
540
549
                 "containing this list of absent files has been written in the current directory.\n";
541
550
        }
542
551
    }
554
563
    exit 1;
555
564
}
556
565
 
 
566
sub isIntltoolExtractInPath
 
567
{
 
568
    my ($file) = @_;
 
569
    # If either a file exists, or when run it returns 0 exit status
 
570
    return 1 if ((-x $file) or (system("$file >/dev/null") == 0));
 
571
    return 0;
 
572
}
 
573
 
557
574
sub GenerateHeaders
558
575
{
559
 
    my $EXTRACT = "@INTLTOOL_EXTRACT@";
560
 
    chomp $EXTRACT;
561
 
 
562
 
    $EXTRACT = $ENV{"INTLTOOL_EXTRACT"} if $ENV{"INTLTOOL_EXTRACT"};
 
576
    my $EXTRACT = $ENV{"INTLTOOL_EXTRACT"} || "intltool-extract";
563
577
 
564
578
    ## Generate the .h header files, so we can allow glade and
565
579
    ## xml translation support
566
 
    if (! -x "$EXTRACT")
 
580
    if (! isIntltoolExtractInPath("$EXTRACT"))
567
581
    {
568
582
        print STDERR "\n *** The intltool-extract script wasn't found!"
569
583
             ."\n *** Without it, intltool-update can not generate files.\n";
610
624
#
611
625
sub GeneratePOTemplate
612
626
{
613
 
    my $XGETTEXT = $ENV{"XGETTEXT"} || "/usr/bin/xgettext";
 
627
    my $XGETTEXT = $ENV{"XGETTEXT"} || "@INTLTOOL_XGETTEXT@";
614
628
    my $XGETTEXT_ARGS = $ENV{"XGETTEXT_ARGS"} || '';
615
629
    chomp $XGETTEXT;
616
630
 
670
684
        } 
671
685
        else 
672
686
        {
673
 
            if ($SRCDIR eq ".") {
674
 
                print OUTFILE "../$_\n";
675
 
            } else {
676
 
                print OUTFILE "$SRCDIR/../$_\n";
677
 
            }
678
 
            $gettext_code = &TextFile_DetermineEncoding ("../$_") if ($gettext_support_nonascii and not defined $forced_gettext_code);
 
687
            print OUTFILE "$SRCDIR/../$_\n";
 
688
            $gettext_code = &TextFile_DetermineEncoding ("$SRCDIR/../$_") if ($gettext_support_nonascii and not defined $forced_gettext_code);
679
689
        }
680
690
 
681
691
        next if (! $gettext_support_nonascii);
721
731
                           "--files-from\=\.\/POTFILES\.in\.temp");
722
732
    my $XGETTEXT_KEYWORDS = &FindPOTKeywords;
723
733
    push @xgettext_argument, $XGETTEXT_KEYWORDS;
 
734
    my $MSGID_BUGS_ADDRESS = &FindMakevarsBugAddress;
 
735
    push @xgettext_argument, "--msgid-bugs-address\=$MSGID_BUGS_ADDRESS" if $MSGID_BUGS_ADDRESS;
724
736
    push @xgettext_argument, "--from-code\=$encoding" if ($gettext_support_nonascii);
725
737
    push @xgettext_argument, $XGETTEXT_ARGS if $XGETTEXT_ARGS;
726
738
    my $xgettext_command = join ' ', @xgettext_argument;
781
793
{
782
794
    -f "$MODULE.pot" or die "$PROGRAM: $MODULE.pot does not exist.\n";
783
795
 
784
 
    my $MSGMERGE = $ENV{"MSGMERGE"} || "/usr/bin/msgmerge";
 
796
    my $MSGMERGE = $ENV{"MSGMERGE"} || "@INTLTOOL_MSGMERGE@";
785
797
    my ($lang, $outfile) = @_;
786
798
 
787
799
    print "Merging $SRCDIR/$lang.po with $MODULE.pot..." if $VERBOSE;
824
836
sub Console_Write_TranslationStatus
825
837
{
826
838
    my ($lang, $output_file) = @_;
827
 
    my $MSGFMT = $ENV{"MSGFMT"} || "/usr/bin/msgfmt";
 
839
    my $MSGFMT = $ENV{"MSGFMT"} || "@INTLTOOL_MSGFMT@";
828
840
 
829
841
    $output_file = "$SRCDIR/$lang.po" if ($output_file eq "");
830
842
 
833
845
 
834
846
sub Console_Write_CoverageReport
835
847
{
836
 
    my $MSGFMT = $ENV{"MSGFMT"} || "/usr/bin/msgfmt";
 
848
    my $MSGFMT = $ENV{"MSGFMT"} || "@INTLTOOL_MSGFMT@";
837
849
 
838
850
    &GatherPOFiles;
839
851
 
873
885
    {
874
886
        my $rest = $3;
875
887
        my $untouched = $1;
876
 
        my $sub = $varhash{$2};
877
 
        
 
888
        my $sub = "";
 
889
        # Ignore recursive definitions of variables
 
890
        $sub = $varhash{$2} if defined $varhash{$2} and $varhash{$2} !~ /\${?$2}?/;
 
891
 
878
892
        return SubstituteVariable ("$untouched$sub$rest");
879
893
    }
880
894
    
991
1005
        ($name, $version) = ($1, $2);
992
1006
        $name    =~ s/[\[\]\s]//g;
993
1007
        $version =~ s/[\[\]\s]//g;
994
 
        $varhash{"AC_PACKAGE_NAME"} = $name;
995
 
        $varhash{"PACKAGE"} = $name;
996
 
        $varhash{"AC_PACKAGE_VERSION"} = $version;
997
 
        $varhash{"VERSION"} = $version;
 
1008
        $varhash{"PACKAGE_NAME"} = $name if (not $name =~ /\${?AC_PACKAGE_NAME}?/);
 
1009
        $varhash{"PACKAGE"} = $name if (not $name =~ /\${?PACKAGE}?/);
 
1010
        $varhash{"PACKAGE_VERSION"} = $version if (not $name =~ /\${?AC_PACKAGE_VERSION}?/);
 
1011
        $varhash{"VERSION"} = $version if (not $name =~ /\${?VERSION}?/);
998
1012
    }
999
1013
    
1000
1014
    if ($conf_source =~ /^AC_INIT\(([^,\)]+),([^,\)]+)/m) 
1002
1016
        ($name, $version) = ($1, $2);
1003
1017
        $name    =~ s/[\[\]\s]//g;
1004
1018
        $version =~ s/[\[\]\s]//g;
1005
 
        $varhash{"AC_PACKAGE_NAME"} = $name;
1006
 
        $varhash{"PACKAGE"} = $name;
1007
 
        $varhash{"AC_PACKAGE_VERSION"} = $version;
1008
 
        $varhash{"VERSION"} = $version;
 
1019
        $varhash{"PACKAGE_NAME"} = $name if (not $name =~ /\${?AC_PACKAGE_NAME}?/);
 
1020
        $varhash{"PACKAGE"} = $name if (not $name =~ /\${?PACKAGE}?/);
 
1021
        $varhash{"PACKAGE_VERSION"} = $version if (not $name =~ /\${?AC_PACKAGE_VERSION}?/);
 
1022
        $varhash{"VERSION"} = $version if (not $name =~ /\${?VERSION}?/);
1009
1023
    }
1010
1024
 
1011
1025
    # \s makes this not work, why?
1012
1026
    $name = $1 if $conf_source =~ /^GETTEXT_PACKAGE=\[?([^\n\]]+)/m;
1013
1027
    
1014
 
    # prepend '$' to auto* internal variables, usually they are
1015
 
    # used in configure.in/ac without the '$'
1016
 
    $name =~ s/AC_/\$AC_/g;
1017
 
    $name =~ s/\$\$/\$/g;
 
1028
    # m4 macros AC_PACKAGE_NAME, AC_PACKAGE_VERSION etc. have same value
 
1029
    # as corresponding $PACKAGE_NAME, $PACKAGE_VERSION etc. shell variables.
 
1030
    $name =~ s/\bAC_PACKAGE_/\$PACKAGE_/g;
1018
1031
 
1019
1032
    $name = $domain if $domain;
1020
1033
 
1063
1076
    
1064
1077
    return $domain;
1065
1078
}
 
1079
 
 
1080
sub FindMakevarsBugAddress
 
1081
{
 
1082
 
 
1083
    my $address = "";
 
1084
    my $makevars_source; { 
 
1085
        local (*IN);
 
1086
        open (IN, "<Makevars") || return undef;
 
1087
        seek (IN, 0, 0);
 
1088
        local $/; # slurp mode
 
1089
        $makevars_source = <IN>;
 
1090
        close IN;
 
1091
    }
 
1092
 
 
1093
    $address = $1 if $makevars_source =~ /^MSGID_BUGS_ADDRESS[ ]*=\[?([^\n\]\$]+)/m;
 
1094
    $address =~ s/^\s+//;
 
1095
    $address =~ s/\s+$//;
 
1096
    
 
1097
    return $address;
 
1098
}