~ubuntu-branches/ubuntu/wily/xfce4-appfinder/wily-proposed

« back to all changes in this revision

Viewing changes to intltool-update.in

  • Committer: Bazaar Package Importer
  • Author(s): Simon Huggins, Yves-Alexis Perez, Simon Huggins
  • Date: 2007-11-27 16:39:17 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20071127163917-b6no7r2t7ee1gy0h
Tags: 4.4.2-1
[ Yves-Alexis Perez ]
* New upstream release.
* debian/menu: switch to new menu policy.
* debian/rules: don't ignore all make errors at clean stage.

[ Simon Huggins ]
* debian/control: Move fake Homepage field to a real one now dpkg
  supports it.
* Add Vcs-* headers to debian/control

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.33";
 
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
my $devnull = ($^O eq 'MSWin32' ? 'NUL:' : '/dev/null');
 
99
 
98
100
## Handle options
99
101
GetOptions 
100
102
(
121
123
 
122
124
&Console_Write_IntltoolHelp if $arg_count > 1;
123
125
 
 
126
my $PKGNAME = FindPackageName ();
 
127
 
124
128
# --version and --help don't require a module name
125
 
my $MODULE = $GETTEXT_PACKAGE || &FindPackageName;
 
129
my $MODULE = $GETTEXT_PACKAGE || $PKGNAME || "unknown";
126
130
 
127
131
if ($POT_ARG)
128
132
{
313
317
        @buf_potfiles_ignore,
314
318
        @buf_allfiles,
315
319
        @buf_allfiles_sorted,
316
 
        @buf_potfiles_sorted
 
320
        @buf_potfiles_sorted,
 
321
        @buf_potfiles_ignore_sorted
317
322
    );
318
323
 
319
324
    ## Search and find all translatable files
339
344
    ## comparing with POTFILES.in
340
345
    foreach my $ignore ("POTFILES.skip", "POTFILES.ignore")
341
346
    {
342
 
        (-s $ignore) or next;
 
347
        (-s "$SRCDIR/$ignore") or next;
343
348
 
344
349
        if ("$ignore" eq "POTFILES.ignore")
345
350
        {
348
353
        }
349
354
 
350
355
        print "Found $ignore: Ignoring files...\n" if $VERBOSE;
351
 
        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";
352
357
            
353
358
        while (<FILE>)
354
359
        {
356
361
        }
357
362
        close FILE;
358
363
 
359
 
        @buf_potfiles = (@buf_potfiles_ignore, @buf_potfiles);
 
364
        @buf_potfiles_ignore_sorted = sort (@buf_potfiles_ignore);
360
365
    }
361
366
 
362
367
    foreach my $file (@buf_i18n_plain)
414
419
                }
415
420
            }       
416
421
 
417
 
            if (/\.GetString ?\(QUOTEDTEXT/)
 
422
            if (/\w\.GetString *\(QUOTEDTEXT/)
418
423
            {
419
424
                if (defined isNotValidMissing (unpack("x3 A*", $file))) {
420
425
                    ## Remove the first 3 chars and add newline
423
428
                last;
424
429
            }
425
430
 
426
 
            if (/_\(QUOTEDTEXT/)
 
431
            ## N_ Q_ and _ are the three macros defined in gi8n.h
 
432
            if (/[NQ]?_ *\(QUOTEDTEXT/)
427
433
            {
428
434
                if (defined isNotValidMissing (unpack("x3 A*", $file))) {
429
435
                    ## Remove the first 3 chars and add newline
442
448
        while (<FILE>) 
443
449
        {
444
450
            # FIXME: share the pattern matching code with intltool-extract
445
 
            if (/\s_(.*)=\"/ || /<_[^>]+>/ || /translatable=\"yes\"/)
 
451
            if (/\s_[-A-Za-z0-9._:]+\s*=\s*\"([^"]+)\"/ || /<_[^>]+>/ || /translatable=\"yes\"/)
446
452
            {
447
453
                if (defined isNotValidMissing (unpack("x3 A*", $file))) {
448
454
                    push @buf_allfiles, unpack("x3 A*", $file) . "\n";
486
492
        $in2{$_} = 1;
487
493
    }
488
494
 
 
495
    foreach (@buf_potfiles_ignore_sorted) 
 
496
    {
 
497
        $in2{$_} = 1;
 
498
    }
 
499
 
489
500
    my @result;
490
501
 
491
502
    foreach (@buf_allfiles_sorted)
501
512
    foreach (@buf_potfiles_sorted)
502
513
    {
503
514
        chomp (my $dummy = $_);
504
 
        if ("$dummy" ne "" and ! -f "../$dummy")
 
515
        if ("$dummy" ne "" and !(-f "$SRCDIR/../$dummy" or -f "../$dummy"))
505
516
        {
506
517
            push @buf_potfiles_notexist, $_;
507
518
        }
534
545
            warn "\n" if ($VERBOSE or @result);
535
546
            warn "\e[1mThe following files do not exist anymore:\e[0m\n\n";
536
547
            warn @buf_potfiles_notexist, "\n";
537
 
            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".
538
549
                 "containing this list of absent files has been written in the current directory.\n";
539
550
        }
540
551
    }
554
565
 
555
566
sub GenerateHeaders
556
567
{
557
 
    my $EXTRACT = "@INTLTOOL_EXTRACT@";
 
568
    my $EXTRACT = "/usr/bin/intltool-extract";
558
569
    chomp $EXTRACT;
559
570
 
560
571
    $EXTRACT = $ENV{"INTLTOOL_EXTRACT"} if $ENV{"INTLTOOL_EXTRACT"};
608
619
#
609
620
sub GeneratePOTemplate
610
621
{
611
 
    my $XGETTEXT = $ENV{"XGETTEXT"} || "/opt/local/bin/xgettext";
 
622
    my $XGETTEXT = $ENV{"XGETTEXT"} || "@INTLTOOL_XGETTEXT@";
612
623
    my $XGETTEXT_ARGS = $ENV{"XGETTEXT_ARGS"} || '';
613
624
    chomp $XGETTEXT;
614
625
 
628
639
    my $gettext_support_nonascii = 0;
629
640
 
630
641
    # checks for GNU gettext >= 0.12
631
 
    my $dummy = `$XGETTEXT --version --from-code=UTF-8 >/dev/null 2>/dev/null`;
 
642
    my $dummy = `$XGETTEXT --version --from-code=UTF-8 >$devnull 2>$devnull`;
632
643
    if ($? == 0)
633
644
    {
634
645
        $gettext_support_nonascii = 1;
668
679
        } 
669
680
        else 
670
681
        {
671
 
            if ($SRCDIR eq ".") {
672
 
                print OUTFILE "../$_\n";
673
 
            } else {
674
 
                print OUTFILE "$SRCDIR/../$_\n";
675
 
            }
676
 
            $gettext_code = &TextFile_DetermineEncoding ("../$_") if ($gettext_support_nonascii and not defined $forced_gettext_code);
 
682
            print OUTFILE "$SRCDIR/../$_\n";
 
683
            $gettext_code = &TextFile_DetermineEncoding ("$SRCDIR/../$_") if ($gettext_support_nonascii and not defined $forced_gettext_code);
677
684
        }
678
685
 
679
686
        next if (! $gettext_support_nonascii);
719
726
                           "--files-from\=\.\/POTFILES\.in\.temp");
720
727
    my $XGETTEXT_KEYWORDS = &FindPOTKeywords;
721
728
    push @xgettext_argument, $XGETTEXT_KEYWORDS;
 
729
    my $MSGID_BUGS_ADDRESS = &FindMakevarsBugAddress;
 
730
    push @xgettext_argument, "--msgid-bugs-address\=$MSGID_BUGS_ADDRESS" if $MSGID_BUGS_ADDRESS;
722
731
    push @xgettext_argument, "--from-code\=$encoding" if ($gettext_support_nonascii);
723
732
    push @xgettext_argument, $XGETTEXT_ARGS if $XGETTEXT_ARGS;
724
733
    my $xgettext_command = join ' ', @xgettext_argument;
779
788
{
780
789
    -f "$MODULE.pot" or die "$PROGRAM: $MODULE.pot does not exist.\n";
781
790
 
782
 
    my $MSGMERGE = $ENV{"MSGMERGE"} || "/opt/local/bin/msgmerge";
 
791
    my $MSGMERGE = $ENV{"MSGMERGE"} || "@INTLTOOL_MSGMERGE@";
783
792
    my ($lang, $outfile) = @_;
784
793
 
785
794
    print "Merging $SRCDIR/$lang.po with $MODULE.pot..." if $VERBOSE;
822
831
sub Console_Write_TranslationStatus
823
832
{
824
833
    my ($lang, $output_file) = @_;
825
 
    my $MSGFMT = $ENV{"MSGFMT"} || "/opt/local/bin/msgfmt";
 
834
    my $MSGFMT = $ENV{"MSGFMT"} || "@INTLTOOL_MSGFMT@";
826
835
 
827
836
    $output_file = "$SRCDIR/$lang.po" if ($output_file eq "");
828
837
 
829
 
    system ("$MSGFMT", "-o", "/dev/null", "--statistics", $output_file);
 
838
    system ("$MSGFMT", "-o", "$devnull", "--verbose", $output_file);
830
839
}
831
840
 
832
841
sub Console_Write_CoverageReport
833
842
{
834
 
    my $MSGFMT = $ENV{"MSGFMT"} || "/opt/local/bin/msgfmt";
 
843
    my $MSGFMT = $ENV{"MSGFMT"} || "@INTLTOOL_MSGFMT@";
835
844
 
836
845
    &GatherPOFiles;
837
846
 
846
855
    foreach my $lang (@languages)
847
856
    {
848
857
        print "$lang: ";
849
 
        system ("$MSGFMT", "-o", "/dev/null", "--statistics", "$SRCDIR/$lang.po");
 
858
        system ("$MSGFMT", "-o", "$devnull", "--verbose", "$SRCDIR/$lang.po");
850
859
    }
851
860
}
852
861
 
871
880
    {
872
881
        my $rest = $3;
873
882
        my $untouched = $1;
874
 
        my $sub = $varhash{$2};
875
 
        
 
883
        my $sub = "";
 
884
        # Ignore recursive definitions of variables
 
885
        $sub = $varhash{$2} if defined $varhash{$2} and $varhash{$2} !~ /\${?$2}?/;
 
886
 
876
887
        return SubstituteVariable ("$untouched$sub$rest");
877
888
    }
878
889
    
989
1000
        ($name, $version) = ($1, $2);
990
1001
        $name    =~ s/[\[\]\s]//g;
991
1002
        $version =~ s/[\[\]\s]//g;
992
 
        $varhash{"AC_PACKAGE_NAME"} = $name;
993
 
        $varhash{"PACKAGE"} = $name;
994
 
        $varhash{"AC_PACKAGE_VERSION"} = $version;
995
 
        $varhash{"VERSION"} = $version;
 
1003
        $varhash{"PACKAGE_NAME"} = $name if (not $name =~ /\${?AC_PACKAGE_NAME}?/);
 
1004
        $varhash{"PACKAGE"} = $name if (not $name =~ /\${?PACKAGE}?/);
 
1005
        $varhash{"PACKAGE_VERSION"} = $version if (not $name =~ /\${?AC_PACKAGE_VERSION}?/);
 
1006
        $varhash{"VERSION"} = $version if (not $name =~ /\${?VERSION}?/);
996
1007
    }
997
1008
    
998
1009
    if ($conf_source =~ /^AC_INIT\(([^,\)]+),([^,\)]+)/m) 
1000
1011
        ($name, $version) = ($1, $2);
1001
1012
        $name    =~ s/[\[\]\s]//g;
1002
1013
        $version =~ s/[\[\]\s]//g;
1003
 
        $varhash{"AC_PACKAGE_NAME"} = $name;
1004
 
        $varhash{"PACKAGE"} = $name;
1005
 
        $varhash{"AC_PACKAGE_VERSION"} = $version;
1006
 
        $varhash{"VERSION"} = $version;
 
1014
        $varhash{"PACKAGE_NAME"} = $name if (not $name =~ /\${?AC_PACKAGE_NAME}?/);
 
1015
        $varhash{"PACKAGE"} = $name if (not $name =~ /\${?PACKAGE}?/);
 
1016
        $varhash{"PACKAGE_VERSION"} = $version if (not $name =~ /\${?AC_PACKAGE_VERSION}?/);
 
1017
        $varhash{"VERSION"} = $version if (not $name =~ /\${?VERSION}?/);
1007
1018
    }
1008
1019
 
1009
1020
    # \s makes this not work, why?
1010
1021
    $name = $1 if $conf_source =~ /^GETTEXT_PACKAGE=\[?([^\n\]]+)/m;
1011
1022
    
1012
 
    # prepend '$' to auto* internal variables, usually they are
1013
 
    # used in configure.in/ac without the '$'
1014
 
    $name =~ s/AC_/\$AC_/g;
1015
 
    $name =~ s/\$\$/\$/g;
 
1023
    # m4 macros AC_PACKAGE_NAME, AC_PACKAGE_VERSION etc. have same value
 
1024
    # as corresponding $PACKAGE_NAME, $PACKAGE_VERSION etc. shell variables.
 
1025
    $name =~ s/\bAC_PACKAGE_/\$PACKAGE_/g;
1016
1026
 
1017
1027
    $name = $domain if $domain;
1018
1028
 
1061
1071
    
1062
1072
    return $domain;
1063
1073
}
 
1074
 
 
1075
sub FindMakevarsBugAddress
 
1076
{
 
1077
 
 
1078
    my $address = "";
 
1079
    my $makevars_source; { 
 
1080
        local (*IN);
 
1081
        open (IN, "<Makevars") || return undef;
 
1082
        seek (IN, 0, 0);
 
1083
        local $/; # slurp mode
 
1084
        $makevars_source = <IN>;
 
1085
        close IN;
 
1086
    }
 
1087
 
 
1088
    $address = $1 if $makevars_source =~ /^MSGID_BUGS_ADDRESS[ ]*=\[?([^\n\]\$]+)/m;
 
1089
    $address =~ s/^\s+//;
 
1090
    $address =~ s/\s+$//;
 
1091
    
 
1092
    return $address;
 
1093
}