~ubuntu-branches/ubuntu/lucid/xfce4-fsguard-plugin/lucid

« back to all changes in this revision

Viewing changes to intltool-update.in

  • Committer: Bazaar Package Importer
  • Author(s): Lionel Le Folgoc
  • Date: 2007-10-23 20:47:52 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20071023204752-k6m9xkmw664l2ywj
Tags: 0.3.99.2-0ubuntu1
* New upstream release (second release candidate):
  - Set default plugin icon to xfce4-fsguard-plugin-warning
  - Rename the "progress bar" to "meter"
  - Fix size of plugin and border around the GtkProgressBar
  - Reworked option dialog
  - A fixed intltool-merge script.
* debian/patches/01_fix-ftbfs-kfreebsd.patch: dropped, included upstream.
* LP: #64429 fixed since the first release candidate.

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.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
80
81
"directory(?:\\.in)+|". # http://www.freedesktop.org/Standards/menu-spec
81
82
"soundlist(?:\\.in)+|". # GNOME specific
82
83
"keys(?:\\.in)+|".      # GNOME Mime database specific
83
 
"theme(?:\\.in)+";      # http://www.freedesktop.org/Standards/icon-theme-spec
 
84
"theme(?:\\.in)+|".     # http://www.freedesktop.org/Standards/icon-theme-spec
 
85
"service(?:\\.in)+";    # DBus specific
84
86
 
85
87
my $buildin_gettext_support = 
86
88
"c|y|cs|cc|cpp|c\\+\\+|h|hh|gob|py";
89
91
$| = 1;
90
92
 
91
93
## Sometimes the source tree will be rooted somewhere else.
92
 
my $SRCDIR = ".";
 
94
my $SRCDIR = $ENV{"srcdir"} || ".";
93
95
my $POTFILES_in;
94
96
 
95
 
$SRCDIR = $ENV{"srcdir"} if $ENV{"srcdir"};
96
97
$POTFILES_in = "<$SRCDIR/POTFILES.in";
97
98
 
 
99
my $devnull = ($^O eq 'MSWin32' ? 'NUL:' : '/dev/null');
 
100
 
98
101
## Handle options
99
102
GetOptions 
100
103
(
121
124
 
122
125
&Console_Write_IntltoolHelp if $arg_count > 1;
123
126
 
 
127
my $PKGNAME = FindPackageName ();
 
128
 
124
129
# --version and --help don't require a module name
125
 
my $MODULE = $GETTEXT_PACKAGE || &FindPackageName;
 
130
my $MODULE = $GETTEXT_PACKAGE || $PKGNAME || "unknown";
126
131
 
127
132
if ($POT_ARG)
128
133
{
313
318
        @buf_potfiles_ignore,
314
319
        @buf_allfiles,
315
320
        @buf_allfiles_sorted,
316
 
        @buf_potfiles_sorted
 
321
        @buf_potfiles_sorted,
 
322
        @buf_potfiles_ignore_sorted
317
323
    );
318
324
 
319
325
    ## Search and find all translatable files
323
329
        push @buf_i18n_ini,          "$File::Find::name" if /\.($ini_support)$/;
324
330
        push @buf_i18n_xml_unmarked, "$File::Find::name" if /\.(schemas(\.in)+)$/;
325
331
        }, "..";
326
 
 
 
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/..";
327
338
 
328
339
    open POTFILES, $POTFILES_in or die "$PROGRAM:  there's no POTFILES.in!\n";
329
340
    @buf_potfiles = grep !/^(#|\s*$)/, <POTFILES>;
339
350
    ## comparing with POTFILES.in
340
351
    foreach my $ignore ("POTFILES.skip", "POTFILES.ignore")
341
352
    {
342
 
        (-s $ignore) or next;
 
353
        (-s "$SRCDIR/$ignore") or next;
343
354
 
344
355
        if ("$ignore" eq "POTFILES.ignore")
345
356
        {
348
359
        }
349
360
 
350
361
        print "Found $ignore: Ignoring files...\n" if $VERBOSE;
351
 
        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";
352
363
            
353
364
        while (<FILE>)
354
365
        {
356
367
        }
357
368
        close FILE;
358
369
 
359
 
        @buf_potfiles = (@buf_potfiles_ignore, @buf_potfiles);
 
370
        @buf_potfiles_ignore_sorted = sort (@buf_potfiles_ignore);
360
371
    }
361
372
 
362
373
    foreach my $file (@buf_i18n_plain)
414
425
                }
415
426
            }       
416
427
 
417
 
            if (/\.GetString ?\(QUOTEDTEXT/)
 
428
            if (/\w\.GetString *\(QUOTEDTEXT/)
418
429
            {
419
430
                if (defined isNotValidMissing (unpack("x3 A*", $file))) {
420
431
                    ## Remove the first 3 chars and add newline
423
434
                last;
424
435
            }
425
436
 
426
 
            if (/_\(QUOTEDTEXT/)
 
437
            ## N_ Q_ and _ are the three macros defined in gi8n.h
 
438
            if (/[NQ]?_ *\(QUOTEDTEXT/)
427
439
            {
428
440
                if (defined isNotValidMissing (unpack("x3 A*", $file))) {
429
441
                    ## Remove the first 3 chars and add newline
442
454
        while (<FILE>) 
443
455
        {
444
456
            # FIXME: share the pattern matching code with intltool-extract
445
 
            if (/\s_(.*)=\"/ || /<_[^>]+>/ || /translatable=\"yes\"/)
 
457
            if (/\s_[-A-Za-z0-9._:]+\s*=\s*\"([^"]+)\"/ || /<_[^>]+>/ || /translatable=\"yes\"/)
446
458
            {
447
459
                if (defined isNotValidMissing (unpack("x3 A*", $file))) {
448
460
                    push @buf_allfiles, unpack("x3 A*", $file) . "\n";
483
495
    my %in2;
484
496
    foreach (@buf_potfiles_sorted) 
485
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/##;
486
507
        $in2{$_} = 1;
487
508
    }
488
509
 
490
511
 
491
512
    foreach (@buf_allfiles_sorted)
492
513
    {
493
 
        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}))
494
522
        {
495
 
            push @result, $_
 
523
            push @result, $dummy
496
524
        }
497
525
    }
498
526
 
501
529
    foreach (@buf_potfiles_sorted)
502
530
    {
503
531
        chomp (my $dummy = $_);
504
 
        if ("$dummy" ne "" and ! -f "../$dummy")
 
532
        if ("$dummy" ne "" and !(-f "$SRCDIR/../$dummy" or -f "../$dummy"))
505
533
        {
506
534
            push @buf_potfiles_notexist, $_;
507
535
        }
534
562
            warn "\n" if ($VERBOSE or @result);
535
563
            warn "\e[1mThe following files do not exist anymore:\e[0m\n\n";
536
564
            warn @buf_potfiles_notexist, "\n";
537
 
            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".
538
566
                 "containing this list of absent files has been written in the current directory.\n";
539
567
        }
540
568
    }
552
580
    exit 1;
553
581
}
554
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
 
555
603
sub GenerateHeaders
556
604
{
557
 
    my $EXTRACT = "@INTLTOOL_EXTRACT@";
558
 
    chomp $EXTRACT;
559
 
 
560
 
    $EXTRACT = $ENV{"INTLTOOL_EXTRACT"} if $ENV{"INTLTOOL_EXTRACT"};
 
605
    my $EXTRACT = $ENV{"INTLTOOL_EXTRACT"} || "intltool-extract";
561
606
 
562
607
    ## Generate the .h header files, so we can allow glade and
563
608
    ## xml translation support
564
 
    if (! -x "$EXTRACT")
 
609
    if (! isProgramInPath ("$EXTRACT"))
565
610
    {
566
611
        print STDERR "\n *** The intltool-extract script wasn't found!"
567
612
             ."\n *** Without it, intltool-update can not generate files.\n";
608
653
#
609
654
sub GeneratePOTemplate
610
655
{
611
 
    my $XGETTEXT = $ENV{"XGETTEXT"} || "/usr/bin/xgettext";
 
656
    my $XGETTEXT = $ENV{"XGETTEXT"} || "xgettext";
612
657
    my $XGETTEXT_ARGS = $ENV{"XGETTEXT_ARGS"} || '';
613
658
    chomp $XGETTEXT;
614
659
 
615
 
    if (! -x $XGETTEXT)
 
660
    if (! isGNUGettextTool ("$XGETTEXT"))
616
661
    {
617
 
        print STDERR " *** xgettext is not found on this system!\n".
 
662
        print STDERR " *** GNU xgettext is not found on this system!\n".
618
663
                     " *** Without it, intltool-update can not extract strings.\n";
619
664
        exit;
620
665
    }
628
673
    my $gettext_support_nonascii = 0;
629
674
 
630
675
    # checks for GNU gettext >= 0.12
631
 
    my $dummy = `$XGETTEXT --version --from-code=UTF-8 >/dev/null 2>/dev/null`;
 
676
    my $dummy = `$XGETTEXT --version --from-code=UTF-8 >$devnull 2>$devnull`;
632
677
    if ($? == 0)
633
678
    {
634
679
        $gettext_support_nonascii = 1;
668
713
        } 
669
714
        else 
670
715
        {
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);
 
716
            print OUTFILE "$SRCDIR/../$_\n";
 
717
            $gettext_code = &TextFile_DetermineEncoding ("$SRCDIR/../$_") if ($gettext_support_nonascii and not defined $forced_gettext_code);
677
718
        }
678
719
 
679
720
        next if (! $gettext_support_nonascii);
714
755
    unlink "$MODULE.pot";
715
756
    my @xgettext_argument=("$XGETTEXT",
716
757
                           "--add-comments",
717
 
                           "--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",
718
775
                           "--output\=$MODULE\.pot",
719
776
                           "--files-from\=\.\/POTFILES\.in\.temp");
720
777
    my $XGETTEXT_KEYWORDS = &FindPOTKeywords;
721
778
    push @xgettext_argument, $XGETTEXT_KEYWORDS;
 
779
    my $MSGID_BUGS_ADDRESS = &FindMakevarsBugAddress;
 
780
    push @xgettext_argument, "--msgid-bugs-address\=$MSGID_BUGS_ADDRESS" if $MSGID_BUGS_ADDRESS;
722
781
    push @xgettext_argument, "--from-code\=$encoding" if ($gettext_support_nonascii);
723
782
    push @xgettext_argument, $XGETTEXT_ARGS if $XGETTEXT_ARGS;
724
783
    my $xgettext_command = join ' ', @xgettext_argument;
779
838
{
780
839
    -f "$MODULE.pot" or die "$PROGRAM: $MODULE.pot does not exist.\n";
781
840
 
782
 
    my $MSGMERGE = $ENV{"MSGMERGE"} || "/usr/bin/msgmerge";
 
841
    my $MSGMERGE = $ENV{"MSGMERGE"} || "msgmerge";
783
842
    my ($lang, $outfile) = @_;
784
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
 
785
851
    print "Merging $SRCDIR/$lang.po with $MODULE.pot..." if $VERBOSE;
786
852
 
787
853
    my $infile = "$SRCDIR/$lang.po";
822
888
sub Console_Write_TranslationStatus
823
889
{
824
890
    my ($lang, $output_file) = @_;
825
 
    my $MSGFMT = $ENV{"MSGFMT"} || "/usr/bin/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
    }
826
899
 
827
900
    $output_file = "$SRCDIR/$lang.po" if ($output_file eq "");
828
901
 
829
 
    system ("$MSGFMT", "-o", "/dev/null", "--statistics", $output_file);
 
902
    system ("$MSGFMT", "-o", "$devnull", "--verbose", $output_file);
830
903
}
831
904
 
832
905
sub Console_Write_CoverageReport
833
906
{
834
 
    my $MSGFMT = $ENV{"MSGFMT"} || "/usr/bin/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
    }
835
915
 
836
916
    &GatherPOFiles;
837
917
 
838
918
    foreach my $lang (@languages) 
839
919
    {
840
 
        print "$lang: ";
 
920
        print STDERR "$lang: ";
841
921
        &POFile_Update ($lang, "");
842
922
    }
843
923
 
844
 
    print "\n\n * Current translation support in $MODULE \n\n";
 
924
    print STDERR "\n\n * Current translation support in $MODULE \n\n";
845
925
 
846
926
    foreach my $lang (@languages)
847
927
    {
848
 
        print "$lang: ";
849
 
        system ("$MSGFMT", "-o", "/dev/null", "--statistics", "$SRCDIR/$lang.po");
 
928
        print STDERR "$lang: ";
 
929
        system ("$MSGFMT", "-o", "$devnull", "--verbose", "$SRCDIR/$lang.po");
850
930
    }
851
931
}
852
932
 
871
951
    {
872
952
        my $rest = $3;
873
953
        my $untouched = $1;
874
 
        my $sub = $varhash{$2};
875
 
        
 
954
        my $sub = "";
 
955
        # Ignore recursive definitions of variables
 
956
        $sub = $varhash{$2} if defined $varhash{$2} and $varhash{$2} !~ /\${?$2}?/;
 
957
 
876
958
        return SubstituteVariable ("$untouched$sub$rest");
877
959
    }
878
960
    
917
999
 
918
1000
            $conf_in || die "Cannot find top_builddir in Makevars.";
919
1001
        }
920
 
        elsif (-f "../configure.ac") 
 
1002
        elsif (-f "$SRCDIR/../configure.ac") 
921
1003
        {
922
 
            $conf_in = "../configure.ac";
 
1004
            $conf_in = "$SRCDIR/../configure.ac";
923
1005
        } 
924
 
        elsif (-f "../configure.in") 
 
1006
        elsif (-f "$SRCDIR/../configure.in") 
925
1007
        {
926
 
            $conf_in = "../configure.in";
 
1008
            $conf_in = "$SRCDIR/../configure.in";
927
1009
        } 
928
1010
        else 
929
1011
        {
989
1071
        ($name, $version) = ($1, $2);
990
1072
        $name    =~ s/[\[\]\s]//g;
991
1073
        $version =~ s/[\[\]\s]//g;
992
 
        $varhash{"AC_PACKAGE_NAME"} = $name;
993
 
        $varhash{"PACKAGE"} = $name;
994
 
        $varhash{"AC_PACKAGE_VERSION"} = $version;
995
 
        $varhash{"VERSION"} = $version;
 
1074
        $varhash{"PACKAGE_NAME"} = $name if (not $name =~ /\${?AC_PACKAGE_NAME}?/);
 
1075
        $varhash{"PACKAGE"} = $name if (not $name =~ /\${?PACKAGE}?/);
 
1076
        $varhash{"PACKAGE_VERSION"} = $version if (not $name =~ /\${?AC_PACKAGE_VERSION}?/);
 
1077
        $varhash{"VERSION"} = $version if (not $name =~ /\${?VERSION}?/);
996
1078
    }
997
1079
    
998
1080
    if ($conf_source =~ /^AC_INIT\(([^,\)]+),([^,\)]+)/m) 
1000
1082
        ($name, $version) = ($1, $2);
1001
1083
        $name    =~ s/[\[\]\s]//g;
1002
1084
        $version =~ s/[\[\]\s]//g;
1003
 
        $varhash{"AC_PACKAGE_NAME"} = $name;
1004
 
        $varhash{"PACKAGE"} = $name;
1005
 
        $varhash{"AC_PACKAGE_VERSION"} = $version;
1006
 
        $varhash{"VERSION"} = $version;
 
1085
        $varhash{"PACKAGE_NAME"} = $name if (not $name =~ /\${?AC_PACKAGE_NAME}?/);
 
1086
        $varhash{"PACKAGE"} = $name if (not $name =~ /\${?PACKAGE}?/);
 
1087
        $varhash{"PACKAGE_VERSION"} = $version if (not $name =~ /\${?AC_PACKAGE_VERSION}?/);
 
1088
        $varhash{"VERSION"} = $version if (not $name =~ /\${?VERSION}?/);
1007
1089
    }
1008
1090
 
1009
1091
    # \s makes this not work, why?
1010
1092
    $name = $1 if $conf_source =~ /^GETTEXT_PACKAGE=\[?([^\n\]]+)/m;
1011
1093
    
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;
 
1094
    # m4 macros AC_PACKAGE_NAME, AC_PACKAGE_VERSION etc. have same value
 
1095
    # as corresponding $PACKAGE_NAME, $PACKAGE_VERSION etc. shell variables.
 
1096
    $name =~ s/\bAC_PACKAGE_/\$PACKAGE_/g;
1016
1097
 
1017
1098
    $name = $domain if $domain;
1018
1099
 
1061
1142
    
1062
1143
    return $domain;
1063
1144
}
 
1145
 
 
1146
sub FindMakevarsBugAddress
 
1147
{
 
1148
 
 
1149
    my $address = "";
 
1150
    my $makevars_source; { 
 
1151
        local (*IN);
 
1152
        open (IN, "<Makevars") || return undef;
 
1153
        seek (IN, 0, 0);
 
1154
        local $/; # slurp mode
 
1155
        $makevars_source = <IN>;
 
1156
        close IN;
 
1157
    }
 
1158
 
 
1159
    $address = $1 if $makevars_source =~ /^MSGID_BUGS_ADDRESS[ ]*=\[?([^\n\]\$]+)/m;
 
1160
    $address =~ s/^\s+//;
 
1161
    $address =~ s/\s+$//;
 
1162
    
 
1163
    return $address;
 
1164
}