~ubuntu-branches/ubuntu/maverick/intltool/maverick

« back to all changes in this revision

Viewing changes to intltool-update.in.in

  • Committer: Bazaar Package Importer
  • Author(s): Loic Minier
  • Date: 2007-08-03 09:36:48 UTC
  • mfrom: (1.2.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20070803093648-o43vt3wh40i99lpu
Tags: 0.36.0-1
* New upstream release.
  - Drop patch 70_fix-intltool-extract-check, merged upstream.
  - Drop patch 71_m4-warnings, merged upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
328
329
        push @buf_i18n_ini,          "$File::Find::name" if /\.($ini_support)$/;
329
330
        push @buf_i18n_xml_unmarked, "$File::Find::name" if /\.(schemas(\.in)+)$/;
330
331
        }, "..";
331
 
 
 
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/..";
332
338
 
333
339
    open POTFILES, $POTFILES_in or die "$PROGRAM:  there's no POTFILES.in!\n";
334
340
    @buf_potfiles = grep !/^(#|\s*$)/, <POTFILES>;
489
495
    my %in2;
490
496
    foreach (@buf_potfiles_sorted) 
491
497
    {
 
498
        s#^$SRCDIR/../##;
 
499
        s#^$SRCDIR/##;
492
500
        $in2{$_} = 1;
493
501
    }
494
502
 
495
503
    foreach (@buf_potfiles_ignore_sorted) 
496
504
    {
 
505
        s#^$SRCDIR/../##;
 
506
        s#^$SRCDIR/##;
497
507
        $in2{$_} = 1;
498
508
    }
499
509
 
501
511
 
502
512
    foreach (@buf_allfiles_sorted)
503
513
    {
504
 
        if (!exists($in2{$_}))
 
514
        my $dummy = $_;
 
515
        my $srcdir = $SRCDIR;
 
516
 
 
517
        $srcdir =~ s#^../##;
 
518
        $dummy =~ s#^$srcdir/../##;
 
519
        $dummy =~ s#^$srcdir/##;
 
520
        if (!exists($in2{$dummy}))
505
521
        {
506
 
            push @result, $_
 
522
            push @result, $dummy
507
523
        }
508
524
    }
509
525
 
563
579
    exit 1;
564
580
}
565
581
 
 
582
sub isProgramInPath
 
583
{
 
584
    my ($file) = @_;
 
585
    # If either a file exists, or when run it returns 0 exit status
 
586
    return 1 if ((-x $file) or (system("$file --version >$devnull") == 0));
 
587
    return 0;
 
588
}
 
589
 
 
590
sub isGNUGettextTool
 
591
{
 
592
    my ($file) = @_;
 
593
    # Check that we are using GNU gettext tools
 
594
    if (isProgramInPath ($file))
 
595
    {
 
596
        my $version = `$file --version`;
 
597
        return 1 if ($version =~ m/.*\(GNU .*\).*/);
 
598
    }
 
599
    return 0;
 
600
}
 
601
 
566
602
sub GenerateHeaders
567
603
{
568
604
    my $EXTRACT = $ENV{"INTLTOOL_EXTRACT"} || "intltool-extract";
569
605
 
570
606
    ## Generate the .h header files, so we can allow glade and
571
607
    ## xml translation support
572
 
    if (! -x "$EXTRACT")
 
608
    if (! isProgramInPath ("$EXTRACT"))
573
609
    {
574
610
        print STDERR "\n *** The intltool-extract script wasn't found!"
575
611
             ."\n *** Without it, intltool-update can not generate files.\n";
616
652
#
617
653
sub GeneratePOTemplate
618
654
{
619
 
    my $XGETTEXT = $ENV{"XGETTEXT"} || "@INTLTOOL_XGETTEXT@";
 
655
    my $XGETTEXT = $ENV{"XGETTEXT"} || "xgettext";
620
656
    my $XGETTEXT_ARGS = $ENV{"XGETTEXT_ARGS"} || '';
621
657
    chomp $XGETTEXT;
622
658
 
623
 
    if (! -x $XGETTEXT)
 
659
    if (! isGNUGettextTool ("$XGETTEXT"))
624
660
    {
625
 
        print STDERR " *** xgettext is not found on this system!\n".
 
661
        print STDERR " *** GNU xgettext is not found on this system!\n".
626
662
                     " *** Without it, intltool-update can not extract strings.\n";
627
663
        exit;
628
664
    }
718
754
    unlink "$MODULE.pot";
719
755
    my @xgettext_argument=("$XGETTEXT",
720
756
                           "--add-comments",
721
 
                           "--directory\=\.",
 
757
                           "--directory\=.",
 
758
                           "--default-domain\=$MODULE",
 
759
                           "--flag\=g_strdup_printf:1:c-format",
 
760
                           "--flag\=g_string_printf:2:c-format",
 
761
                           "--flag\=g_string_append_printf:2:c-format",
 
762
                           "--flag\=g_error_new:3:c-format",
 
763
                           "--flag\=g_set_error:4:c-format",
 
764
                           "--flag\=g_markup_printf_escaped:1:c-format",
 
765
                           "--flag\=g_log:3:c-format",
 
766
                           "--flag\=g_print:1:c-format",
 
767
                           "--flag\=g_printerr:1:c-format",
 
768
                           "--flag\=g_printf:1:c-format",
 
769
                           "--flag\=g_fprintf:2:c-format",
 
770
                           "--flag\=g_sprintf:2:c-format",
 
771
                           "--flag\=g_snprintf:3:c-format",
 
772
                           "--flag\=g_scanner_error:2:c-format",
 
773
                           "--flag\=g_scanner_warn:2:c-format",
722
774
                           "--output\=$MODULE\.pot",
723
775
                           "--files-from\=\.\/POTFILES\.in\.temp");
724
776
    my $XGETTEXT_KEYWORDS = &FindPOTKeywords;
785
837
{
786
838
    -f "$MODULE.pot" or die "$PROGRAM: $MODULE.pot does not exist.\n";
787
839
 
788
 
    my $MSGMERGE = $ENV{"MSGMERGE"} || "@INTLTOOL_MSGMERGE@";
 
840
    my $MSGMERGE = $ENV{"MSGMERGE"} || "msgmerge";
789
841
    my ($lang, $outfile) = @_;
790
842
 
 
843
    if (! isGNUGettextTool ("$MSGMERGE"))
 
844
    {
 
845
        print STDERR " *** GNU msgmerge is not found on this system!\n".
 
846
                     " *** Without it, intltool-update can not extract strings.\n";
 
847
        exit;
 
848
    }
 
849
 
791
850
    print "Merging $SRCDIR/$lang.po with $MODULE.pot..." if $VERBOSE;
792
851
 
793
852
    my $infile = "$SRCDIR/$lang.po";
828
887
sub Console_Write_TranslationStatus
829
888
{
830
889
    my ($lang, $output_file) = @_;
831
 
    my $MSGFMT = $ENV{"MSGFMT"} || "@INTLTOOL_MSGFMT@";
 
890
    my $MSGFMT = $ENV{"MSGFMT"} || "msgfmt";
 
891
 
 
892
    if (! isGNUGettextTool ("$MSGFMT"))
 
893
    {
 
894
        print STDERR " *** GNU msgfmt is not found on this system!\n".
 
895
                     " *** Without it, intltool-update can not extract strings.\n";
 
896
        exit;
 
897
    }
832
898
 
833
899
    $output_file = "$SRCDIR/$lang.po" if ($output_file eq "");
834
900
 
837
903
 
838
904
sub Console_Write_CoverageReport
839
905
{
840
 
    my $MSGFMT = $ENV{"MSGFMT"} || "@INTLTOOL_MSGFMT@";
 
906
    my $MSGFMT = $ENV{"MSGFMT"} || "msgfmt";
 
907
 
 
908
    if (! isGNUGettextTool ("$MSGFMT"))
 
909
    {
 
910
        print STDERR " *** GNU msgfmt is not found on this system!\n".
 
911
                     " *** Without it, intltool-update can not extract strings.\n";
 
912
        exit;
 
913
    }
841
914
 
842
915
    &GatherPOFiles;
843
916