mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 04:08:01 +02:00
+ Versions from intltool 0.34 are back, magically work after new
. autogen.sh run!? Tim git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1124 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
7899ecc6b3
commit
b7c6f8ba3b
3 changed files with 419 additions and 53 deletions
|
|
@ -32,7 +32,7 @@
|
|||
## Release information
|
||||
my $PROGRAM = "intltool-extract";
|
||||
my $PACKAGE = "intltool";
|
||||
my $VERSION = "0.33";
|
||||
my $VERSION = "0.34.1";
|
||||
|
||||
## Loaded modules
|
||||
use strict;
|
||||
|
|
@ -59,6 +59,8 @@ my %count = ();
|
|||
my %comments = ();
|
||||
my $strcount = 0;
|
||||
|
||||
my $XMLCOMMENT = "";
|
||||
|
||||
## Use this instead of \w for XML files to handle more possible characters.
|
||||
my $w = "[-A-Za-z0-9._:]";
|
||||
|
||||
|
|
@ -186,6 +188,7 @@ sub extract {
|
|||
&convert;
|
||||
|
||||
open OUT, ">$OUTFILE";
|
||||
binmode (OUT) if $^O eq 'MSWin32';
|
||||
&msg_write;
|
||||
close OUT;
|
||||
|
||||
|
|
@ -266,24 +269,344 @@ sub type_keys {
|
|||
|
||||
sub type_xml {
|
||||
### For generic translatable XML files ###
|
||||
|
||||
while ($input =~ /(?:<!--([^>]*?)-->[^\n]*\n?[^\n]*)?\s_$w+\s*=\s*\"([^"]*)\"/sg) { # "
|
||||
$messages{entity_decode_minimal($2)} = [];
|
||||
$comments{entity_decode_minimal($2)} = $1 if (defined($1));
|
||||
my $tree = readXml($input);
|
||||
parseTree(0, $tree);
|
||||
}
|
||||
|
||||
sub print_var {
|
||||
my $var = shift;
|
||||
my $vartype = ref $var;
|
||||
|
||||
if ($vartype =~ /ARRAY/) {
|
||||
my @arr = @{$var};
|
||||
print "[ ";
|
||||
foreach my $el (@arr) {
|
||||
print_var($el);
|
||||
print ", ";
|
||||
}
|
||||
print "] ";
|
||||
} elsif ($vartype =~ /HASH/) {
|
||||
my %hash = %{$var};
|
||||
print "{ ";
|
||||
foreach my $key (keys %hash) {
|
||||
print "$key => ";
|
||||
print_var($hash{$key});
|
||||
print ", ";
|
||||
}
|
||||
print "} ";
|
||||
} else {
|
||||
print $var;
|
||||
}
|
||||
}
|
||||
|
||||
# Same syntax as getAttributeString in intltool-merge.in.in, similar logic (look for ## differences comment)
|
||||
sub getAttributeString
|
||||
{
|
||||
my $sub = shift;
|
||||
my $do_translate = shift || 1;
|
||||
my $language = shift || "";
|
||||
my $translate = shift;
|
||||
my $result = "";
|
||||
foreach my $e (reverse(sort(keys %{ $sub }))) {
|
||||
my $key = $e;
|
||||
my $string = $sub->{$e};
|
||||
my $quote = '"';
|
||||
|
||||
$string =~ s/^[\s]+//;
|
||||
$string =~ s/[\s]+$//;
|
||||
|
||||
if ($string =~ /^'.*'$/)
|
||||
{
|
||||
$quote = "'";
|
||||
}
|
||||
$string =~ s/^['"]//g;
|
||||
$string =~ s/['"]$//g;
|
||||
|
||||
## differences from intltool-merge.in.in
|
||||
if ($key =~ /^_/) {
|
||||
$comments{entity_decode($string)} = $XMLCOMMENT if $XMLCOMMENT;
|
||||
$messages{entity_decode($string)} = [];
|
||||
$$translate = 2;
|
||||
}
|
||||
## differences end here from intltool-merge.in.in
|
||||
$result .= " $key=$quote$string$quote";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
# Verbatim copy from intltool-merge.in.in
|
||||
sub getXMLstring
|
||||
{
|
||||
my $ref = shift;
|
||||
my $spacepreserve = shift || 0;
|
||||
my @list = @{ $ref };
|
||||
my $result = "";
|
||||
|
||||
my $count = scalar(@list);
|
||||
my $attrs = $list[0];
|
||||
my $index = 1;
|
||||
|
||||
$spacepreserve = 1 if ((exists $attrs->{"xml:space"}) && ($attrs->{"xml:space"} =~ /^["']?preserve["']?$/));
|
||||
$spacepreserve = 0 if ((exists $attrs->{"xml:space"}) && ($attrs->{"xml:space"} =~ /^["']?default["']?$/));
|
||||
|
||||
while ($index < $count) {
|
||||
my $type = $list[$index];
|
||||
my $content = $list[$index+1];
|
||||
if (! $type ) {
|
||||
# We've got CDATA
|
||||
if ($content) {
|
||||
# lets strip the whitespace here, and *ONLY* here
|
||||
$content =~ s/\s+/ /gs if (!$spacepreserve);
|
||||
$result .= $content;
|
||||
}
|
||||
} elsif ( "$type" ne "1" ) {
|
||||
# We've got another element
|
||||
$result .= "<$type";
|
||||
$result .= getAttributeString(@{$content}[0], 0); # no nested translatable elements
|
||||
if ($content) {
|
||||
my $subresult = getXMLstring($content, $spacepreserve);
|
||||
if ($subresult) {
|
||||
$result .= ">".$subresult . "</$type>";
|
||||
} else {
|
||||
$result .= "/>";
|
||||
}
|
||||
} else {
|
||||
$result .= "/>";
|
||||
}
|
||||
}
|
||||
$index += 2;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
# Verbatim copy from intltool-merge.in.in, except for MULTIPLE_OUTPUT handling removed
|
||||
# Translate list of nodes if necessary
|
||||
sub translate_subnodes
|
||||
{
|
||||
my $fh = shift;
|
||||
my $content = shift;
|
||||
my $language = shift || "";
|
||||
my $singlelang = shift || 0;
|
||||
my $spacepreserve = shift || 0;
|
||||
|
||||
my @nodes = @{ $content };
|
||||
|
||||
my $count = scalar(@nodes);
|
||||
my $index = 0;
|
||||
while ($index < $count) {
|
||||
my $type = $nodes[$index];
|
||||
my $rest = $nodes[$index+1];
|
||||
traverse($fh, $type, $rest, $language, $spacepreserve);
|
||||
$index += 2;
|
||||
}
|
||||
}
|
||||
|
||||
# Based on traverse() in intltool-merge.in.in
|
||||
sub traverse
|
||||
{
|
||||
my $fh = shift; # unused, to allow us to sync code between -merge and -extract
|
||||
my $nodename = shift;
|
||||
my $content = shift;
|
||||
my $language = shift || "";
|
||||
my $spacepreserve = shift || 0;
|
||||
|
||||
if ($nodename && "$nodename" eq "1") {
|
||||
$XMLCOMMENT = $content;
|
||||
} elsif ($nodename) {
|
||||
# element
|
||||
my @all = @{ $content };
|
||||
my $attrs = shift @all;
|
||||
my $translate = 0;
|
||||
my $outattr = getAttributeString($attrs, 1, $language, \$translate);
|
||||
|
||||
if ($nodename =~ /^_/) {
|
||||
$translate = 1;
|
||||
$nodename =~ s/^_//;
|
||||
}
|
||||
my $lookup = '';
|
||||
|
||||
$spacepreserve = 0 if ((exists $attrs->{"xml:space"}) && ($attrs->{"xml:space"} =~ /^["']?default["']?$/));
|
||||
$spacepreserve = 1 if ((exists $attrs->{"xml:space"}) && ($attrs->{"xml:space"} =~ /^["']?preserve["']?$/));
|
||||
|
||||
if ($translate) {
|
||||
$lookup = getXMLstring($content, $spacepreserve);
|
||||
if (!$spacepreserve) {
|
||||
$lookup =~ s/^\s+//s;
|
||||
$lookup =~ s/\s+$//s;
|
||||
}
|
||||
|
||||
if ($lookup && $translate != 2) {
|
||||
$comments{$lookup} = $XMLCOMMENT if $XMLCOMMENT;
|
||||
$messages{$lookup} = [];
|
||||
} elsif ($translate == 2) {
|
||||
translate_subnodes($fh, \@all, $language, 1, $spacepreserve);
|
||||
}
|
||||
} else {
|
||||
$XMLCOMMENT = "";
|
||||
my $count = scalar(@all);
|
||||
if ($count > 0) {
|
||||
my $index = 0;
|
||||
while ($index < $count) {
|
||||
my $type = $all[$index];
|
||||
my $rest = $all[$index+1];
|
||||
traverse($fh, $type, $rest, $language, $spacepreserve);
|
||||
$index += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
$XMLCOMMENT = "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Verbatim copy from intltool-merge.in.in, $fh for compatibility
|
||||
sub parseTree
|
||||
{
|
||||
my $fh = shift;
|
||||
my $ref = shift;
|
||||
my $language = shift || "";
|
||||
|
||||
my $name = shift @{ $ref };
|
||||
my $cont = shift @{ $ref };
|
||||
|
||||
while (!$name || "$name" eq "1") {
|
||||
$name = shift @{ $ref };
|
||||
$cont = shift @{ $ref };
|
||||
}
|
||||
|
||||
while ($input =~ /(?:<!--([^>]*?)-->\s*)?<_($w+)(?: xml:space="($w+)")?[^>]*>(.*?)<\/_\2>/sg) {
|
||||
$_ = $4;
|
||||
if (!defined($3) || $3 ne "preserve") {
|
||||
s/\s+/ /g;
|
||||
s/^ //;
|
||||
s/ $//;
|
||||
}
|
||||
$messages{$_} = [];
|
||||
$comments{$_} = $1 if (defined($1));
|
||||
my $spacepreserve = 0;
|
||||
my $attrs = @{$cont}[0];
|
||||
$spacepreserve = 1 if ((exists $attrs->{"xml:space"}) && ($attrs->{"xml:space"} =~ /^["']?preserve["']?$/));
|
||||
|
||||
traverse($fh, $name, $cont, $language, $spacepreserve);
|
||||
}
|
||||
|
||||
# Verbatim copy from intltool-merge.in.in
|
||||
sub intltool_tree_comment
|
||||
{
|
||||
my $expat = shift;
|
||||
my $data = shift;
|
||||
my $clist = $expat->{Curlist};
|
||||
my $pos = $#$clist;
|
||||
|
||||
push @$clist, 1 => $data;
|
||||
}
|
||||
|
||||
# Verbatim copy from intltool-merge.in.in
|
||||
sub intltool_tree_cdatastart
|
||||
{
|
||||
my $expat = shift;
|
||||
my $clist = $expat->{Curlist};
|
||||
my $pos = $#$clist;
|
||||
|
||||
push @$clist, 0 => $expat->original_string();
|
||||
}
|
||||
|
||||
# Verbatim copy from intltool-merge.in.in
|
||||
sub intltool_tree_cdataend
|
||||
{
|
||||
my $expat = shift;
|
||||
my $clist = $expat->{Curlist};
|
||||
my $pos = $#$clist;
|
||||
|
||||
$clist->[$pos] .= $expat->original_string();
|
||||
}
|
||||
|
||||
# Verbatim copy from intltool-merge.in.in
|
||||
sub intltool_tree_char
|
||||
{
|
||||
my $expat = shift;
|
||||
my $text = shift;
|
||||
my $clist = $expat->{Curlist};
|
||||
my $pos = $#$clist;
|
||||
|
||||
# Use original_string so that we retain escaped entities
|
||||
# in CDATA sections.
|
||||
#
|
||||
if ($pos > 0 and $clist->[$pos - 1] eq '0') {
|
||||
$clist->[$pos] .= $expat->original_string();
|
||||
} else {
|
||||
push @$clist, 0 => $expat->original_string();
|
||||
}
|
||||
}
|
||||
|
||||
# Verbatim copy from intltool-merge.in.in
|
||||
sub intltool_tree_start
|
||||
{
|
||||
my $expat = shift;
|
||||
my $tag = shift;
|
||||
my @origlist = ();
|
||||
|
||||
# Use original_string so that we retain escaped entities
|
||||
# in attribute values. We must convert the string to an
|
||||
# @origlist array to conform to the structure of the Tree
|
||||
# Style.
|
||||
#
|
||||
my @original_array = split /\x/, $expat->original_string();
|
||||
my $source = $expat->original_string();
|
||||
|
||||
# Remove leading tag.
|
||||
#
|
||||
$source =~ s|^\s*<\s*(\S+)||s;
|
||||
|
||||
# Grab attribute key/value pairs and push onto @origlist array.
|
||||
#
|
||||
while ($source)
|
||||
{
|
||||
if ($source =~ /^\s*([\w:-]+)\s*[=]\s*["]/)
|
||||
{
|
||||
$source =~ s|^\s*([\w:-]+)\s*[=]\s*["]([^"]*)["]||s;
|
||||
push @origlist, $1;
|
||||
push @origlist, '"' . $2 . '"';
|
||||
}
|
||||
elsif ($source =~ /^\s*([\w:-]+)\s*[=]\s*[']/)
|
||||
{
|
||||
$source =~ s|^\s*([\w:-]+)\s*[=]\s*[']([^']*)[']||s;
|
||||
push @origlist, $1;
|
||||
push @origlist, "'" . $2 . "'";
|
||||
}
|
||||
else
|
||||
{
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
my $ol = [ { @origlist } ];
|
||||
|
||||
push @{ $expat->{Lists} }, $expat->{Curlist};
|
||||
push @{ $expat->{Curlist} }, $tag => $ol;
|
||||
$expat->{Curlist} = $ol;
|
||||
}
|
||||
|
||||
# Copied from intltool-merge.in.in and added comment handler.
|
||||
sub readXml
|
||||
{
|
||||
my $xmldoc = shift || return;
|
||||
my $ret = eval 'require XML::Parser';
|
||||
if(!$ret) {
|
||||
die "You must have XML::Parser installed to run $0\n\n";
|
||||
}
|
||||
my $xp = new XML::Parser(Style => 'Tree');
|
||||
$xp->setHandlers(Char => \&intltool_tree_char);
|
||||
$xp->setHandlers(Start => \&intltool_tree_start);
|
||||
$xp->setHandlers(CdataStart => \&intltool_tree_cdatastart);
|
||||
$xp->setHandlers(CdataEnd => \&intltool_tree_cdataend);
|
||||
|
||||
## differences from intltool-merge.in.in
|
||||
$xp->setHandlers(Comment => \&intltool_tree_comment);
|
||||
## differences end here from intltool-merge.in.in
|
||||
|
||||
my $tree = $xp->parse($xmldoc);
|
||||
#print_var($tree);
|
||||
|
||||
# <foo><!-- comment --><head id="a">Hello <em>there</em></head><bar>Howdy<ref/></bar>do</foo>
|
||||
# would be:
|
||||
# [foo, [{}, 1, "comment", head, [{id => "a"}, 0, "Hello ", em, [{}, 0, "there"]], bar,
|
||||
# [{}, 0, "Howdy", ref, [{}]], 0, "do" ] ]
|
||||
|
||||
return $tree;
|
||||
}
|
||||
|
||||
sub type_schemas {
|
||||
### For schemas XML files ###
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
## Release information
|
||||
my $PROGRAM = "intltool-merge";
|
||||
my $PACKAGE = "intltool";
|
||||
my $VERSION = "0.33";
|
||||
my $VERSION = "0.34.1";
|
||||
|
||||
## Loaded modules
|
||||
use strict;
|
||||
|
|
@ -92,6 +92,7 @@ my $OUTFILE;
|
|||
my %po_files_by_lang = ();
|
||||
my %translations = ();
|
||||
my $iconv = $ENV{"ICONV"} || $ENV{"INTLTOOL_ICONV"} || "/usr/bin/iconv";
|
||||
my $devnull = ($^O eq 'MSWin32' ? 'NUL:' : '/dev/null');
|
||||
|
||||
# Use this instead of \w for XML files to handle more possible characters.
|
||||
my $w = "[-A-Za-z0-9._:]";
|
||||
|
|
@ -299,7 +300,7 @@ sub get_po_encoding
|
|||
$encoding = "ISO-8859-1";
|
||||
}
|
||||
|
||||
system ("$iconv -f $encoding -t UTF-8 </dev/null 2>/dev/null");
|
||||
system ("$iconv -f $encoding -t UTF-8 <$devnull 2>$devnull");
|
||||
if ($?) {
|
||||
$encoding = get_local_charset($encoding);
|
||||
}
|
||||
|
|
@ -542,6 +543,8 @@ sub ba_merge_translations
|
|||
}
|
||||
|
||||
open OUTPUT, ">$OUTFILE" or die "can't open $OUTFILE: $!";
|
||||
# Binmode so that selftest works ok if using a native Win32 Perl...
|
||||
binmode (OUTPUT) if $^O eq 'MSWin32';
|
||||
|
||||
while ($source =~ s|^(.*?)([ \t]*<\s*$w+\s+($w+\s*=\s*"$q"\s*)+/?>)([ \t]*\n)?||s)
|
||||
{
|
||||
|
|
@ -610,23 +613,16 @@ sub getAttributeString
|
|||
if ($do_translate && $key =~ /^_/) {
|
||||
$key =~ s|^_||g;
|
||||
if ($language) {
|
||||
|
||||
# Handle translation
|
||||
#
|
||||
my $decode_string = entity_decode($string);
|
||||
my $translation = $translations{$language, $decode_string};
|
||||
if ($translation) {
|
||||
$translation = entity_encode($translation);
|
||||
$string = $translation;
|
||||
$$translate = 2;
|
||||
} else {
|
||||
$$translate = 2; # we still want translations for deep nesting (FIXME: this will cause
|
||||
# problems since we might get untranslated duplicated entries, but with xml:lang set)
|
||||
# Fix would be to set it here to eg. 3, and do a check in traverse() to see if any of the containing tags
|
||||
# really need translation, and only emit "translation" if there is (this means parsing same data twice)
|
||||
}
|
||||
$$translate = 2;
|
||||
} else {
|
||||
$$translate = 2 if ($translate && (!$$translate)); # watch not to "overwrite" if $translate == 2
|
||||
$$translate = 2 if ($translate && (!$$translate)); # watch not to "overwrite" $translate
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -636,13 +632,10 @@ sub getAttributeString
|
|||
}
|
||||
|
||||
# Returns a translatable string from XML node, it works on contents of every node in XML::Parser tree
|
||||
# doesn't support nesting of translatable tags (i.e. <_blah>this <_doh>doesn't</_doh> work</_blah> -- besides
|
||||
# can you define the correct semantics for this?)
|
||||
#
|
||||
|
||||
sub getXMLstring
|
||||
{
|
||||
my $ref = shift;
|
||||
my $spacepreserve = shift || 0;
|
||||
my @list = @{ $ref };
|
||||
my $result = "";
|
||||
|
||||
|
|
@ -650,6 +643,9 @@ sub getXMLstring
|
|||
my $attrs = $list[0];
|
||||
my $index = 1;
|
||||
|
||||
$spacepreserve = 1 if ((exists $attrs->{"xml:space"}) && ($attrs->{"xml:space"} =~ /^["']?preserve["']?$/));
|
||||
$spacepreserve = 0 if ((exists $attrs->{"xml:space"}) && ($attrs->{"xml:space"} =~ /^["']?default["']?$/));
|
||||
|
||||
while ($index < $count) {
|
||||
my $type = $list[$index];
|
||||
my $content = $list[$index+1];
|
||||
|
|
@ -657,19 +653,15 @@ sub getXMLstring
|
|||
# We've got CDATA
|
||||
if ($content) {
|
||||
# lets strip the whitespace here, and *ONLY* here
|
||||
$content =~ s/\s+/ /gs if (!((exists $attrs->{"xml:space"}) && ($attrs->{"xml:space"} =~ /^["']?preserve["']?$/)));
|
||||
$result .= ($content);
|
||||
} else {
|
||||
#print "no cdata content when expected it\n"; # is this possible, is this ok?
|
||||
# what to do if this happens?
|
||||
# Did I mention that I hate XML::Parser tree style?
|
||||
$content =~ s/\s+/ /gs if (!$spacepreserve);
|
||||
$result .= $content;
|
||||
}
|
||||
} else {
|
||||
} elsif ( "$type" ne "1" ) {
|
||||
# We've got another element
|
||||
$result .= "<$type";
|
||||
$result .= getAttributeString(@{$content}[0], 0); # no nested translatable elements
|
||||
if ($content) {
|
||||
my $subresult = getXMLstring($content);
|
||||
my $subresult = getXMLstring($content, $spacepreserve);
|
||||
if ($subresult) {
|
||||
$result .= ">".$subresult . "</$type>";
|
||||
} else {
|
||||
|
|
@ -691,6 +683,7 @@ sub translate_subnodes
|
|||
my $content = shift;
|
||||
my $language = shift || "";
|
||||
my $singlelang = shift || 0;
|
||||
my $spacepreserve = shift || 0;
|
||||
|
||||
my @nodes = @{ $content };
|
||||
|
||||
|
|
@ -702,21 +695,39 @@ sub translate_subnodes
|
|||
if ($singlelang) {
|
||||
my $oldMO = $MULTIPLE_OUTPUT;
|
||||
$MULTIPLE_OUTPUT = 1;
|
||||
traverse($fh, $type, $rest, $language);
|
||||
traverse($fh, $type, $rest, $language, $spacepreserve);
|
||||
$MULTIPLE_OUTPUT = $oldMO;
|
||||
} else {
|
||||
traverse($fh, $type, $rest, $language);
|
||||
traverse($fh, $type, $rest, $language, $spacepreserve);
|
||||
}
|
||||
$index += 2;
|
||||
}
|
||||
}
|
||||
|
||||
sub isWellFormedXmlFragment
|
||||
{
|
||||
my $ret = eval 'require XML::Parser';
|
||||
if(!$ret) {
|
||||
die "You must have XML::Parser installed to run $0\n\n";
|
||||
}
|
||||
|
||||
my $fragment = shift;
|
||||
return 0 if (!$fragment);
|
||||
|
||||
$fragment = "<root>$fragment</root>";
|
||||
my $xp = new XML::Parser(Style => 'Tree');
|
||||
my $tree = 0;
|
||||
eval { $tree = $xp->parse($fragment); };
|
||||
return $tree;
|
||||
}
|
||||
|
||||
sub traverse
|
||||
{
|
||||
my $fh = shift;
|
||||
my $nodename = shift;
|
||||
my $content = shift;
|
||||
my $language = shift || "";
|
||||
my $spacepreserve = shift || 0;
|
||||
|
||||
if (!$nodename) {
|
||||
if ($content =~ /^[\s]*$/) {
|
||||
|
|
@ -735,22 +746,26 @@ sub traverse
|
|||
$nodename =~ s/^_//;
|
||||
}
|
||||
my $lookup = '';
|
||||
|
||||
$spacepreserve = 0 if ((exists $attrs->{"xml:space"}) && ($attrs->{"xml:space"} =~ /^["']?default["']?$/));
|
||||
$spacepreserve = 1 if ((exists $attrs->{"xml:space"}) && ($attrs->{"xml:space"} =~ /^["']?preserve["']?$/));
|
||||
|
||||
print $fh "<$nodename", $outattr;
|
||||
if ($translate) {
|
||||
$lookup = getXMLstring($content);
|
||||
if (!((exists $attrs->{"xml:space"}) && ($attrs->{"xml:space"} =~ /^["']?preserve["']?$/))) {
|
||||
$lookup = getXMLstring($content, $spacepreserve);
|
||||
if (!$spacepreserve) {
|
||||
$lookup =~ s/^\s+//s;
|
||||
$lookup =~ s/\s+$//s;
|
||||
}
|
||||
|
||||
if ($lookup || $translate == 2) {
|
||||
my $translation = $translations{$language, $lookup};
|
||||
my $translation = $translations{$language, $lookup} if isWellFormedXmlFragment($translations{$language, $lookup});
|
||||
if ($MULTIPLE_OUTPUT && ($translation || $translate == 2)) {
|
||||
$translation = $lookup if (!$translation);
|
||||
print $fh " xml:lang=\"", $language, "\"" if $language;
|
||||
print $fh ">";
|
||||
if ($translate == 2) {
|
||||
translate_subnodes($fh, \@all, $language, 1);
|
||||
translate_subnodes($fh, \@all, $language, 1, $spacepreserve);
|
||||
} else {
|
||||
print $fh $translation;
|
||||
}
|
||||
|
|
@ -761,7 +776,7 @@ sub traverse
|
|||
} else {
|
||||
print $fh ">";
|
||||
if ($translate == 2) {
|
||||
translate_subnodes($fh, \@all, $language, 1);
|
||||
translate_subnodes($fh, \@all, $language, 1, $spacepreserve);
|
||||
} else {
|
||||
print $fh $lookup;
|
||||
}
|
||||
|
|
@ -780,7 +795,7 @@ sub traverse
|
|||
#
|
||||
my $translate = 0;
|
||||
my $localattrs = getAttributeString($attrs, 1, $lang, \$translate);
|
||||
my $translation = $translations{$lang, $lookup};
|
||||
my $translation = $translations{$lang, $lookup} if isWellFormedXmlFragment($translations{$lang, $lookup});
|
||||
if ($translate && !$translation) {
|
||||
$translation = $lookup;
|
||||
}
|
||||
|
|
@ -791,7 +806,7 @@ sub traverse
|
|||
print $fh $leading_space;
|
||||
print $fh "<", $nodename, " xml:lang=\"", $lang, "\"", $localattrs, ">";
|
||||
if ($translate == 2) {
|
||||
translate_subnodes($fh, \@all, $lang, 1);
|
||||
translate_subnodes($fh, \@all, $lang, 1, $spacepreserve);
|
||||
} else {
|
||||
print $fh $translation;
|
||||
}
|
||||
|
|
@ -808,7 +823,7 @@ sub traverse
|
|||
while ($index < $count) {
|
||||
my $type = $all[$index];
|
||||
my $rest = $all[$index+1];
|
||||
traverse($fh, $type, $rest, $language);
|
||||
traverse($fh, $type, $rest, $language, $spacepreserve);
|
||||
$index += 2;
|
||||
}
|
||||
print $fh "</$nodename>";
|
||||
|
|
@ -819,6 +834,16 @@ sub traverse
|
|||
}
|
||||
}
|
||||
|
||||
sub intltool_tree_comment
|
||||
{
|
||||
my $expat = shift;
|
||||
my $data = shift;
|
||||
my $clist = $expat->{Curlist};
|
||||
my $pos = $#$clist;
|
||||
|
||||
push @$clist, 1 => $data;
|
||||
}
|
||||
|
||||
sub intltool_tree_cdatastart
|
||||
{
|
||||
my $expat = shift;
|
||||
|
|
@ -962,7 +987,17 @@ sub parseTree
|
|||
|
||||
my $name = shift @{ $ref };
|
||||
my $cont = shift @{ $ref };
|
||||
traverse($fh, $name, $cont, $language);
|
||||
|
||||
while (!$name || "$name" eq "1") {
|
||||
$name = shift @{ $ref };
|
||||
$cont = shift @{ $ref };
|
||||
}
|
||||
|
||||
my $spacepreserve = 0;
|
||||
my $attrs = @{$cont}[0];
|
||||
$spacepreserve = 1 if ((exists $attrs->{"xml:space"}) && ($attrs->{"xml:space"} =~ /^["']?preserve["']?$/));
|
||||
|
||||
traverse($fh, $name, $cont, $language, $spacepreserve);
|
||||
}
|
||||
|
||||
sub xml_merge_output
|
||||
|
|
@ -975,6 +1010,7 @@ sub xml_merge_output
|
|||
mkdir $lang or die "Cannot create subdirectory $lang: $!\n";
|
||||
}
|
||||
open OUTPUT, ">$lang/$OUTFILE" or die "Cannot open $lang/$OUTFILE: $!\n";
|
||||
binmode (OUTPUT) if $^O eq 'MSWin32';
|
||||
my $tree = readXml($FILE);
|
||||
print_header($FILE, \*OUTPUT);
|
||||
parseTree(\*OUTPUT, $tree, $lang);
|
||||
|
|
@ -983,6 +1019,7 @@ sub xml_merge_output
|
|||
}
|
||||
}
|
||||
open OUTPUT, ">$OUTFILE" or die "Cannot open $OUTFILE: $!\n";
|
||||
binmode (OUTPUT) if $^O eq 'MSWin32';
|
||||
my $tree = readXml($FILE);
|
||||
print_header($FILE, \*OUTPUT);
|
||||
parseTree(\*OUTPUT, $tree);
|
||||
|
|
@ -994,6 +1031,7 @@ sub keys_merge_translations
|
|||
{
|
||||
open INPUT, "<${FILE}" or die;
|
||||
open OUTPUT, ">${OUTFILE}" or die;
|
||||
binmode (OUTPUT) if $^O eq 'MSWin32';
|
||||
|
||||
while (<INPUT>)
|
||||
{
|
||||
|
|
@ -1029,6 +1067,7 @@ sub desktop_merge_translations
|
|||
{
|
||||
open INPUT, "<${FILE}" or die;
|
||||
open OUTPUT, ">${OUTFILE}" or die;
|
||||
binmode (OUTPUT) if $^O eq 'MSWin32';
|
||||
|
||||
while (<INPUT>)
|
||||
{
|
||||
|
|
@ -1072,6 +1111,7 @@ sub schemas_merge_translations
|
|||
}
|
||||
|
||||
open OUTPUT, ">$OUTFILE" or die;
|
||||
binmode (OUTPUT) if $^O eq 'MSWin32';
|
||||
|
||||
# FIXME: support attribute translations
|
||||
|
||||
|
|
@ -1173,6 +1213,7 @@ sub rfc822deb_merge_translations
|
|||
}
|
||||
|
||||
open OUTPUT, ">${OUTFILE}" or die;
|
||||
binmode (OUTPUT) if $^O eq 'MSWin32';
|
||||
|
||||
while ($source =~ /(^|\n+)(_*)([^:\s]+)(:[ \t]*)(.*?)(?=\n[\S\n]|$)/sg)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
## Release information
|
||||
my $PROGRAM = "intltool-update";
|
||||
my $VERSION = "0.33";
|
||||
my $VERSION = "0.34.1";
|
||||
my $PACKAGE = "intltool";
|
||||
|
||||
## Loaded modules
|
||||
|
|
@ -95,6 +95,8 @@ my $POTFILES_in;
|
|||
$SRCDIR = $ENV{"srcdir"} if $ENV{"srcdir"};
|
||||
$POTFILES_in = "<$SRCDIR/POTFILES.in";
|
||||
|
||||
my $devnull = ($^O eq 'MSWin32' ? 'NUL:' : '/dev/null');
|
||||
|
||||
## Handle options
|
||||
GetOptions
|
||||
(
|
||||
|
|
@ -442,7 +444,7 @@ sub FindLeftoutFiles
|
|||
while (<FILE>)
|
||||
{
|
||||
# FIXME: share the pattern matching code with intltool-extract
|
||||
if (/\s_(.*)=\"/ || /<_[^>]+>/ || /translatable=\"yes\"/)
|
||||
if (/\s_[-A-Za-z0-9._:]+\s*=\s*\"([^"]+)\"/ || /<_[^>]+>/ || /translatable=\"yes\"/)
|
||||
{
|
||||
if (defined isNotValidMissing (unpack("x3 A*", $file))) {
|
||||
push @buf_allfiles, unpack("x3 A*", $file) . "\n";
|
||||
|
|
@ -628,7 +630,7 @@ sub GeneratePOTemplate
|
|||
my $gettext_support_nonascii = 0;
|
||||
|
||||
# checks for GNU gettext >= 0.12
|
||||
my $dummy = `$XGETTEXT --version --from-code=UTF-8 >/dev/null 2>/dev/null`;
|
||||
my $dummy = `$XGETTEXT --version --from-code=UTF-8 >$devnull 2>$devnull`;
|
||||
if ($? == 0)
|
||||
{
|
||||
$gettext_support_nonascii = 1;
|
||||
|
|
@ -826,7 +828,7 @@ sub Console_Write_TranslationStatus
|
|||
|
||||
$output_file = "$SRCDIR/$lang.po" if ($output_file eq "");
|
||||
|
||||
system ("$MSGFMT", "-o", "/dev/null", "--statistics", $output_file);
|
||||
system ("$MSGFMT", "-o", "$devnull", "--verbose", $output_file);
|
||||
}
|
||||
|
||||
sub Console_Write_CoverageReport
|
||||
|
|
@ -846,7 +848,7 @@ sub Console_Write_CoverageReport
|
|||
foreach my $lang (@languages)
|
||||
{
|
||||
print "$lang: ";
|
||||
system ("$MSGFMT", "-o", "/dev/null", "--statistics", "$SRCDIR/$lang.po");
|
||||
system ("$MSGFMT", "-o", "$devnull", "--verbose", "$SRCDIR/$lang.po");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue