~ubuntu-branches/ubuntu/feisty/libgnome/feisty

« back to all changes in this revision

Viewing changes to intltool-update.in

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2005-09-07 18:03:53 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050907180353-hf71fcfx1nb0omez
Tags: 2.12.0.1-0ubuntu1
* New upstream realease:
  - Bug fixes
    - Fix schemas install problem with vi translation (Rodney)
  - Updated translations
    - Vietnamese
* debian/patches/fix-vi.po.patch:
  - dropped, done upstream.

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.31.2";
 
33
my $VERSION = "0.33";
34
34
my $PACKAGE = "intltool";
35
35
 
36
36
## Loaded modules
74
74
"kbd(?:\\.in)+";        # GOK specific. 
75
75
 
76
76
my $ini_support =
 
77
"icon(?:\\.in)+|".      # http://www.freedesktop.org/Standards/icon-theme-spec
77
78
"desktop(?:\\.in)+|".   # http://www.freedesktop.org/Standards/menu-spec
78
79
"caves(?:\\.in)+|".     # GNOME Games specific
79
80
"directory(?:\\.in)+|". # http://www.freedesktop.org/Standards/menu-spec
94
95
$SRCDIR = $ENV{"srcdir"} if $ENV{"srcdir"};
95
96
$POTFILES_in = "<$SRCDIR/POTFILES.in";
96
97
 
 
98
my $devnull = ($^O eq 'MSWin32' ? 'NUL:' : '/dev/null');
 
99
 
97
100
## Handle options
98
101
GetOptions 
99
102
(
148
151
 
149
152
    ## Report error if the language file supplied
150
153
    ## to the command line is non-existent
151
 
    &Console_WriteError_NotExisting("$lang.po") if ! -s "$lang.po";
 
154
    &Console_WriteError_NotExisting("$SRCDIR/$lang.po")
 
155
        if ! -s "$SRCDIR/$lang.po";
152
156
 
153
157
    if (!$DIST_ARG)
154
158
    {
211
215
    exit;
212
216
}
213
217
 
 
218
sub echo_n
 
219
{
 
220
    my $str = shift;
 
221
    my $ret = `echo "$str"`;
 
222
 
 
223
    $ret =~ s/\n$//; # do we need the "s" flag?
 
224
 
 
225
    return $ret;
 
226
}
 
227
 
214
228
sub POFile_DetermineType ($) 
215
229
{
216
230
   my $type = $_;
283
297
    return $gettext_code;
284
298
}
285
299
 
 
300
sub isNotValidMissing
 
301
{
 
302
    my ($file) = @_;
 
303
 
 
304
    return if $file =~ /^\{arch\}\/.*$/;
 
305
    return if $file =~ /^$varhash{"PACKAGE"}-$varhash{"VERSION"}\/.*$/;
 
306
}
286
307
 
287
308
sub FindLeftoutFiles
288
309
{
397
418
 
398
419
            if (/\.GetString ?\(QUOTEDTEXT/)
399
420
            {
400
 
                ## Remove the first 3 chars and add newline
401
 
                push @buf_allfiles, unpack("x3 A*", $file) . "\n";
 
421
                if (defined isNotValidMissing (unpack("x3 A*", $file))) {
 
422
                    ## Remove the first 3 chars and add newline
 
423
                    push @buf_allfiles, unpack("x3 A*", $file) . "\n";
 
424
                }
402
425
                last;
403
426
            }
404
427
 
405
428
            if (/_\(QUOTEDTEXT/)
406
429
            {
407
 
                ## Remove the first 3 chars and add newline
408
 
                push @buf_allfiles, unpack("x3 A*", $file) . "\n";
 
430
                if (defined isNotValidMissing (unpack("x3 A*", $file))) {
 
431
                    ## Remove the first 3 chars and add newline
 
432
                    push @buf_allfiles, unpack("x3 A*", $file) . "\n";
 
433
                }
409
434
                last;
410
435
            }
411
436
        }
419
444
        while (<FILE>) 
420
445
        {
421
446
            # FIXME: share the pattern matching code with intltool-extract
422
 
            if (/\s_(.*)=\"/ || /<_[^>]+>/ || /translatable=\"yes\"/)
 
447
            if (/\s_[-A-Za-z0-9._:]+\s*=\s*\"([^"]+)\"/ || /<_[^>]+>/ || /translatable=\"yes\"/)
423
448
            {
424
 
                push @buf_allfiles, unpack("x3 A*", $file) . "\n";
 
449
                if (defined isNotValidMissing (unpack("x3 A*", $file))) {
 
450
                    push @buf_allfiles, unpack("x3 A*", $file) . "\n";
 
451
                }
425
452
                last;
426
453
            }
427
454
        }
435
462
        {
436
463
            if (/_(.*)=/)
437
464
            {
438
 
                push @buf_allfiles, unpack("x3 A*", $file) . "\n";
 
465
                if (defined isNotValidMissing (unpack("x3 A*", $file))) {
 
466
                    push @buf_allfiles, unpack("x3 A*", $file) . "\n";
 
467
                }
439
468
                last;
440
469
            }
441
470
        }
444
473
 
445
474
    foreach my $file (@buf_i18n_xml_unmarked)
446
475
    {
447
 
        push @buf_allfiles, unpack("x3 A*", $file) . "\n";
 
476
        if (defined isNotValidMissing (unpack("x3 A*", $file))) {
 
477
            push @buf_allfiles, unpack("x3 A*", $file) . "\n";
 
478
        }
448
479
    }
449
480
 
450
481
 
525
556
 
526
557
sub GenerateHeaders
527
558
{
528
 
    my $EXTRACT = `which intltool-extract 2>/dev/null`;
 
559
    my $EXTRACT = "@INTLTOOL_EXTRACT@";
529
560
    chomp $EXTRACT;
530
561
 
531
562
    $EXTRACT = $ENV{"INTLTOOL_EXTRACT"} if $ENV{"INTLTOOL_EXTRACT"};
579
610
#
580
611
sub GeneratePOTemplate
581
612
{
582
 
    my $XGETTEXT = `which xgettext 2>/dev/null`;
583
 
    my $XGETTEXT_ARGS = '';
 
613
    my $XGETTEXT = $ENV{"XGETTEXT"} || "/usr/bin/xgettext";
 
614
    my $XGETTEXT_ARGS = $ENV{"XGETTEXT_ARGS"} || '';
584
615
    chomp $XGETTEXT;
585
616
 
586
 
    $XGETTEXT = $ENV{"XGETTEXT"} if $ENV{"XGETTEXT"};
587
 
    $XGETTEXT_ARGS = $ENV{"XGETTEXT_ARGS"} if $ENV{"XGETTEXT_ARGS"};
588
 
 
589
617
    if (! -x $XGETTEXT)
590
618
    {
591
619
        print STDERR " *** xgettext is not found on this system!\n".
597
625
 
598
626
    open INFILE, $POTFILES_in;
599
627
    unlink "POTFILES.in.temp";
600
 
    open OUTFILE, ">POTFILES.in.temp";
 
628
    open OUTFILE, ">POTFILES.in.temp" or die("Cannot open POTFILES.in.temp for writing");
601
629
 
602
630
    my $gettext_support_nonascii = 0;
603
631
 
604
632
    # checks for GNU gettext >= 0.12
605
 
    my $dummy = `$XGETTEXT --version --from-code=UTF-8 >/dev/null 2>/dev/null`;
 
633
    my $dummy = `$XGETTEXT --version --from-code=UTF-8 >$devnull 2>$devnull`;
606
634
    if ($? == 0)
607
635
    {
608
636
        $gettext_support_nonascii = 1;
636
664
        elsif (/\.($xml_support|$ini_support)$/ || /^\[/)
637
665
        {
638
666
            s/^\[.*]\s*//;
639
 
            print OUTFILE "$_.h\n";
 
667
            print OUTFILE "../$_.h\n";
640
668
            push @temp_headers, "../$_.h";
641
669
            $gettext_code = &TextFile_DetermineEncoding ("../$_.h") if ($gettext_support_nonascii and not defined $forced_gettext_code);
642
670
        } 
643
671
        else 
644
672
        {
645
673
            if ($SRCDIR eq ".") {
646
 
                print OUTFILE "$_\n";
 
674
                print OUTFILE "../$_\n";
647
675
            } else {
648
676
                print OUTFILE "$SRCDIR/../$_\n";
649
677
            }
688
716
    unlink "$MODULE.pot";
689
717
    my @xgettext_argument=("$XGETTEXT",
690
718
                           "--add-comments",
691
 
                           "--directory\=\.\.",
 
719
                           "--directory\=\.",
692
720
                           "--output\=$MODULE\.pot",
693
721
                           "--files-from\=\.\/POTFILES\.in\.temp");
694
722
    my $XGETTEXT_KEYWORDS = &FindPOTKeywords;
753
781
{
754
782
    -f "$MODULE.pot" or die "$PROGRAM: $MODULE.pot does not exist.\n";
755
783
 
 
784
    my $MSGMERGE = $ENV{"MSGMERGE"} || "/usr/bin/msgmerge";
756
785
    my ($lang, $outfile) = @_;
757
786
 
758
 
    print "Merging $lang.po with $MODULE.pot..." if $VERBOSE;
 
787
    print "Merging $SRCDIR/$lang.po with $MODULE.pot..." if $VERBOSE;
759
788
 
760
 
    my $infile = "$lang.po";
761
 
    $outfile = "$lang.po" if ($outfile eq "");
 
789
    my $infile = "$SRCDIR/$lang.po";
 
790
    $outfile = "$SRCDIR/$lang.po" if ($outfile eq "");
762
791
 
763
792
    # I think msgmerge won't overwrite old file if merge is not successful
764
 
    system ("msgmerge", "-o", $outfile, $infile, "$MODULE.pot");
 
793
    system ("$MSGMERGE", "-o", $outfile, $infile, "$MODULE.pot");
765
794
}
766
795
 
767
796
sub Console_WriteError_NotExisting
795
824
sub Console_Write_TranslationStatus
796
825
{
797
826
    my ($lang, $output_file) = @_;
798
 
 
799
 
    $output_file = "$lang.po" if ($output_file eq "");
800
 
 
801
 
    system ("msgfmt", "-o", "/dev/null", "--statistics", $output_file);
 
827
    my $MSGFMT = $ENV{"MSGFMT"} || "/usr/bin/msgfmt";
 
828
 
 
829
    $output_file = "$SRCDIR/$lang.po" if ($output_file eq "");
 
830
 
 
831
    system ("$MSGFMT", "-o", "$devnull", "--verbose", $output_file);
802
832
}
803
833
 
804
834
sub Console_Write_CoverageReport
805
835
{
 
836
    my $MSGFMT = $ENV{"MSGFMT"} || "/usr/bin/msgfmt";
 
837
 
806
838
    &GatherPOFiles;
807
839
 
808
840
    foreach my $lang (@languages) 
816
848
    foreach my $lang (@languages)
817
849
    {
818
850
        print "$lang: ";
819
 
        system ("msgfmt", "-o", "/dev/null", "--statistics", "$lang.po");
 
851
        system ("$MSGFMT", "-o", "$devnull", "--verbose", "$SRCDIR/$lang.po");
820
852
    }
821
853
}
822
854
 
833
865
    {
834
866
        if (/^(\w+)=(.*)$/)
835
867
        {
836
 
            ($varhash{$1} = $2) =~  s/^["'](.*)["']$/$1)/;
 
868
            ($varhash{$1} = $2) =~  s/^["'](.*)["']$/$1/;
837
869
        }
838
870
    }
839
871
    
845
877
        
846
878
        return SubstituteVariable ("$untouched$sub$rest");
847
879
    }
848
 
    return $str;
 
880
    
 
881
    # We're using Perl backticks ` and "echo -n" here in order to 
 
882
    # expand any shell escapes (such as backticks themselves) in every variable
 
883
    return echo_n ($str);
849
884
}
850
885
 
851
886
sub CONF_Handle_Open
993
1028
sub FindPOTKeywords
994
1029
{
995
1030
 
996
 
    my $keywords = "--keyword\=\_ --keyword\=N\_ --keyword\=U\_";
 
1031
    my $keywords = "--keyword\=\_ --keyword\=N\_ --keyword\=U\_ --keyword\=Q\_";
997
1032
    my $varname = "XGETTEXT_OPTIONS";
998
1033
    my $make_source; {
999
1034
        local (*IN);