~ubuntu-branches/debian/experimental/intltool/experimental

« back to all changes in this revision

Viewing changes to intltool-update.in.in

  • Committer: Bazaar Package Importer
  • Author(s): Loic Minier
  • Date: 2006-10-24 21:50:28 UTC
  • mfrom: (3.1.5 edgy)
  • Revision ID: james.westby@ubuntu.com-20061024215028-8u8azjmsesm1kqbl
Tags: 0.35.0-3
* Remove debhelper, cdbs, and gnome-pkg-tools from Build-Depends-Indep.
* Remove obsolete Conflicts / Replaces on xml-i18n-tools.
* New patch, 10_define-and-subst-datadirname, to compute DATADIRNAME as
  glib-gettext did it, and AC_SUBST() it; thanks Jurij Smakov; committed in
  upstream CVS; GNOME #345255; closes: #373643.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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";
95
96
$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
(
122
125
&Console_Write_IntltoolHelp if $arg_count > 1;
123
126
 
124
127
# --version and --help don't require a module name
125
 
my $MODULE = $GETTEXT_PACKAGE || &FindPackageName;
 
128
my $MODULE = $GETTEXT_PACKAGE || &FindPackageName || "unknown";
126
129
 
127
130
if ($POT_ARG)
128
131
{
442
445
        while (<FILE>) 
443
446
        {
444
447
            # FIXME: share the pattern matching code with intltool-extract
445
 
            if (/\s_(.*)=\"/ || /<_[^>]+>/ || /translatable=\"yes\"/)
 
448
            if (/\s_[-A-Za-z0-9._:]+\s*=\s*\"([^"]+)\"/ || /<_[^>]+>/ || /translatable=\"yes\"/)
446
449
            {
447
450
                if (defined isNotValidMissing (unpack("x3 A*", $file))) {
448
451
                    push @buf_allfiles, unpack("x3 A*", $file) . "\n";
628
631
    my $gettext_support_nonascii = 0;
629
632
 
630
633
    # checks for GNU gettext >= 0.12
631
 
    my $dummy = `$XGETTEXT --version --from-code=UTF-8 >/dev/null 2>/dev/null`;
 
634
    my $dummy = `$XGETTEXT --version --from-code=UTF-8 >$devnull 2>$devnull`;
632
635
    if ($? == 0)
633
636
    {
634
637
        $gettext_support_nonascii = 1;
719
722
                           "--files-from\=\.\/POTFILES\.in\.temp");
720
723
    my $XGETTEXT_KEYWORDS = &FindPOTKeywords;
721
724
    push @xgettext_argument, $XGETTEXT_KEYWORDS;
 
725
    my $MSGID_BUGS_ADDRESS = &FindMakevarsBugAddress;
 
726
    push @xgettext_argument, "--msgid-bugs-address\=$MSGID_BUGS_ADDRESS" if $MSGID_BUGS_ADDRESS;
722
727
    push @xgettext_argument, "--from-code\=$encoding" if ($gettext_support_nonascii);
723
728
    push @xgettext_argument, $XGETTEXT_ARGS if $XGETTEXT_ARGS;
724
729
    my $xgettext_command = join ' ', @xgettext_argument;
826
831
 
827
832
    $output_file = "$SRCDIR/$lang.po" if ($output_file eq "");
828
833
 
829
 
    system ("$MSGFMT", "-o", "/dev/null", "--statistics", $output_file);
 
834
    system ("$MSGFMT", "-o", "$devnull", "--verbose", $output_file);
830
835
}
831
836
 
832
837
sub Console_Write_CoverageReport
846
851
    foreach my $lang (@languages)
847
852
    {
848
853
        print "$lang: ";
849
 
        system ("$MSGFMT", "-o", "/dev/null", "--statistics", "$SRCDIR/$lang.po");
 
854
        system ("$MSGFMT", "-o", "$devnull", "--verbose", "$SRCDIR/$lang.po");
850
855
    }
851
856
}
852
857
 
871
876
    {
872
877
        my $rest = $3;
873
878
        my $untouched = $1;
874
 
        my $sub = $varhash{$2};
875
 
        
 
879
        my $sub = "";
 
880
        # Ignore recursive definitions of variables
 
881
        $sub = $varhash{$2} if defined $varhash{$2} and $varhash{$2} !~ /\${?$2}?/;
 
882
 
876
883
        return SubstituteVariable ("$untouched$sub$rest");
877
884
    }
878
885
    
989
996
        ($name, $version) = ($1, $2);
990
997
        $name    =~ s/[\[\]\s]//g;
991
998
        $version =~ s/[\[\]\s]//g;
992
 
        $varhash{"AC_PACKAGE_NAME"} = $name;
993
 
        $varhash{"PACKAGE"} = $name;
994
 
        $varhash{"AC_PACKAGE_VERSION"} = $version;
995
 
        $varhash{"VERSION"} = $version;
 
999
        $varhash{"PACKAGE_NAME"} = $name if (not $name =~ /\${?AC_PACKAGE_NAME}?/);
 
1000
        $varhash{"PACKAGE"} = $name if (not $name =~ /\${?PACKAGE}?/);
 
1001
        $varhash{"PACKAGE_VERSION"} = $version if (not $name =~ /\${?AC_PACKAGE_VERSION}?/);
 
1002
        $varhash{"VERSION"} = $version if (not $name =~ /\${?VERSION}?/);
996
1003
    }
997
1004
    
998
1005
    if ($conf_source =~ /^AC_INIT\(([^,\)]+),([^,\)]+)/m) 
1000
1007
        ($name, $version) = ($1, $2);
1001
1008
        $name    =~ s/[\[\]\s]//g;
1002
1009
        $version =~ s/[\[\]\s]//g;
1003
 
        $varhash{"AC_PACKAGE_NAME"} = $name;
1004
 
        $varhash{"PACKAGE"} = $name;
1005
 
        $varhash{"AC_PACKAGE_VERSION"} = $version;
1006
 
        $varhash{"VERSION"} = $version;
 
1010
        $varhash{"PACKAGE_NAME"} = $name if (not $name =~ /\${?AC_PACKAGE_NAME}?/);
 
1011
        $varhash{"PACKAGE"} = $name if (not $name =~ /\${?PACKAGE}?/);
 
1012
        $varhash{"PACKAGE_VERSION"} = $version if (not $name =~ /\${?AC_PACKAGE_VERSION}?/);
 
1013
        $varhash{"VERSION"} = $version if (not $name =~ /\${?VERSION}?/);
1007
1014
    }
1008
1015
 
1009
1016
    # \s makes this not work, why?
1010
1017
    $name = $1 if $conf_source =~ /^GETTEXT_PACKAGE=\[?([^\n\]]+)/m;
1011
1018
    
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;
 
1019
    # m4 macros AC_PACKAGE_NAME, AC_PACKAGE_VERSION etc. have same value
 
1020
    # as corresponding $PACKAGE_NAME, $PACKAGE_VERSION etc. shell variables.
 
1021
    $name =~ s/\bAC_PACKAGE_/\$PACKAGE_/g;
1016
1022
 
1017
1023
    $name = $domain if $domain;
1018
1024
 
1061
1067
    
1062
1068
    return $domain;
1063
1069
}
 
1070
 
 
1071
sub FindMakevarsBugAddress
 
1072
{
 
1073
 
 
1074
    my $address = "";
 
1075
    my $makevars_source; { 
 
1076
        local (*IN);
 
1077
        open (IN, "<Makevars") || return undef;
 
1078
        seek (IN, 0, 0);
 
1079
        local $/; # slurp mode
 
1080
        $makevars_source = <IN>;
 
1081
        close IN;
 
1082
    }
 
1083
 
 
1084
    $address = $1 if $makevars_source =~ /^MSGID_BUGS_ADDRESS[ ]*=\[?([^\n\]\$]+)/m;
 
1085
    $address =~ s/^\s+//;
 
1086
    $address =~ s/\s+$//;
 
1087
    
 
1088
    return $address;
 
1089
}