Browse Source

added comparison of old and new 'outdated translation' detection mechanisms

svn path=/branches/test/; revision=20735
tags/stw2018
nicoulas 8 years ago
parent
commit
1315d3725b
4 changed files with 87 additions and 66 deletions
  1. 6
    2
      fsfe.xsl
  2. 69
    53
      tools/build-test.pl
  3. 5
    5
      tools/comptree.pl
  4. 7
    6
      tools/translation-log-test.sh

+ 6
- 2
fsfe.xsl View File

@@ -627,8 +627,12 @@
<!-- Outdated note -->
<xsl:if test="/buildinfo/@outdated='yes'">
<xsl:element name="p">
<xsl:attribute name="id">outdated-notice</xsl:attribute>
<xsl:call-template name="fsfe-gettext"><xsl:with-param name="id" select="'outdated'" /></xsl:call-template>
<xsl:attribute name="id">outdated-notice</xsl:attribute>
<xsl:call-template name="fsfe-gettext"><xsl:with-param name="id" select="'outdated'" /></xsl:call-template>
<xsl:copy-of select="/buildinfo/document/outdated-info" />
</xsl:element>
</xsl:if>

+ 69
- 53
tools/build-test.pl View File

@@ -595,6 +595,8 @@ sub process {
#
my $originalsource = "$file.".$root->getAttribute("original").".xhtml";
my $comment;
my $old_outdated = 0;
if (( stat("$opts{i}/$originalsource"))[9] > (stat($source))[9] + 7200
and not $cant_be_outdated{$file} ) {
@@ -602,9 +604,10 @@ sub process {
$old_outdated = 1;
} else {
}
my $new_outdated = 0;
if ( not -e "$opts{i}/$originalsource" ) {
# TODO: do something
@@ -615,22 +618,19 @@ sub process {
if ( not $equal and not $cant_be_outdated{$file} ) {
#print "$err\n";
$root->setAttribute("outdated", "yes");
$new_outdated = 1;
# register information about the outdated status
my $info = $dom->createElement("outdated-info");
my $code = $dom->createElement("code");
$code->appendChild($dom->createElement("br"));
foreach $line (split(/\n/, $err)) {
my $p = $dom->createElement("p");
$p->appendText($line);
$info->appendChild($p);
$code->appendText($line);
$code->appendChild($dom->createElement("br"));
}
$info->appendChild($code);
$document->appendChild($info);
if ($dir eq "global") {
lock(*TRANSLATIONS);
print TRANSLATIONS "$lang $source $originalsource\n";
unlock(*TRANSLATIONS);
}
} else {
$root->setAttribute("outdated", "no");
@@ -638,59 +638,75 @@ sub process {
}
}
if ($dir eq "global" and $new_outdated != $old_outdated ) {
if ( $new_outdated == 0 and $old_outdated == 1 ) {
$comment = "timestamp-OUT,structure-OK";
} elsif ( $new_outdated == 1 and $old_outdated == 0 ) {
$comment = "timestamp-OK,structure-OUT";
} else {
$comment = "-";
}
lock(*TRANSLATIONS);
print TRANSLATIONS "$lang $source $originalsource $comment\n";
unlock(*TRANSLATIONS);
}
#
# Get the appropriate textset for this language. If one can't be
# found, use the English. (I hope this never happens)
#
my $textlang = $lang;
unless (-f $opts{i}."/tools/texts-$textlang.xml") {
$textlang = "en";
}
my $textlang = $lang;
unless (-f $opts{i}."/tools/texts-$textlang.xml") {
$textlang = "en";
}

my $textdoc = $dom->createElement("textset");
$root->appendChild($textdoc);
clone_document($textdoc, $opts{i}."/tools/texts-$textlang.xml");
my $textdoc = $dom->createElement("textset");
$root->appendChild($textdoc);
clone_document($textdoc, $opts{i}."/tools/texts-$textlang.xml");


#
# Read the fundraising text, if it exists.
#
if (-f $opts{i}."/fundraising.$lang.xml") {
my $fundraisingdoc = $dom->createElement("fundraising");
$root->appendChild($fundraisingdoc);
clone_document($fundraisingdoc, $opts{i}."/fundraising.$lang.xml");
} elsif (-f $opts{i}."/fundraising.en.xml") {
my $fundraisingdoc = $dom->createElement("fundraising");
$root->appendChild($fundraisingdoc);
clone_document($fundraisingdoc, $opts{i}."/fundraising.en.xml");
}
#
# Read the fundraising text, if it exists.
#
if (-f $opts{i}."/fundraising.$lang.xml") {
my $fundraisingdoc = $dom->createElement("fundraising");
$root->appendChild($fundraisingdoc);
clone_document($fundraisingdoc, $opts{i}."/fundraising.$lang.xml");
} elsif (-f $opts{i}."/fundraising.en.xml") {
my $fundraisingdoc = $dom->createElement("fundraising");
$root->appendChild($fundraisingdoc);
clone_document($fundraisingdoc, $opts{i}."/fundraising.en.xml");
}


#
# And then we do the same thing for the menues. But first we take the
# global menu here, then we add any information that is specific to
# the focus.
#
foreach ($root->getElementsByTagName("menuset")) {
$root->removeChild($_);
}
my %menu;
foreach ('global', $dir) {
if (-f $opts{i}."/tools/menu-$_.xml") {
my $menudoc = $parser->parse_file($opts{i}."/tools/menu-$_.xml");
foreach my $n ($menudoc->documentElement->getElementsByTagName("menu")) {
$menu{$n->getAttribute("id")} = $n;
}
}
}
my $menuroot = $dom->createElement("menuset");
while (my ($id, $n) = each %menu) {
my $m = $n->cloneNode(1);
$menuroot->appendChild($m);
}
$root->appendChild($menuroot);
#
# And then we do the same thing for the menues. But first we take the
# global menu here, then we add any information that is specific to
# the focus.
#
foreach ($root->getElementsByTagName("menuset")) {
$root->removeChild($_);
}
my %menu;
foreach ('global', $dir) {
if (-f $opts{i}."/tools/menu-$_.xml") {
my $menudoc = $parser->parse_file($opts{i}."/tools/menu-$_.xml");
foreach my $n ($menudoc->documentElement->getElementsByTagName("menu")) {
$menu{$n->getAttribute("id")} = $n;
}
}
}
my $menuroot = $dom->createElement("menuset");
while (my ($id, $n) = each %menu) {
my $m = $n->cloneNode(1);
$menuroot->appendChild($m);
}
$root->appendChild($menuroot);
# <start addendum> (TODO: transform this into a function)

+ 5
- 5
tools/comptree.pl View File

@@ -28,14 +28,14 @@ sub areEqual {
my $root = $dom->documentElement();
my $roon = $don->documentElement();
return nodesAreEqual($file1, $file2, $root, $roon, "/");
return nodesAreEqual($file1, $file2, $root, $roon, "/", '');
}


sub nodesAreEqual {
my ($file1, $file2, $node1, $node2, $uptree) = @_;
my ($file1, $file2, $node1, $node2, $uptree, $nodenb) = @_;
# test that two nodes at the same position have the same name
if (not $node1->nodeName eq $node2->nodeName) {
@@ -54,9 +54,9 @@ sub nodesAreEqual {
"** contains $uptree".$node2->nodeName."\t(".$hint2.")");
}
$uptree .= $node1->nodeName."/";
$uptree .= $node1->nodeName.$nodenb."/";
# get all children of ecah node
# get all children of each node
my @nodes = $node1->getChildrenByTagName('*');
my @nodez = $node2->getChildrenByTagName('*');
@@ -92,7 +92,7 @@ sub nodesAreEqual {
# recur!
for my $i (0 .. $#nodes) {
my ($bool, $err) = nodesAreEqual($file1, $file2, $nodes[$i], $nodez[$i], $uptree);
my ($bool, $err) = nodesAreEqual($file1, $file2, $nodes[$i], $nodez[$i], $uptree, $i);
if (not $bool) {
return ($bool, $err);
}

+ 7
- 6
tools/translation-log-test.sh View File

@@ -24,6 +24,7 @@
# Constants
# -----------------------------------------------------------------------------

testroot="http://test.fsfe.org"
srcroot="http://test.fsfe.org/source"
cvsroot="https://trac.fsfe.org/fsfe-web/log/branches/test"

@@ -67,11 +68,11 @@ done
sort "${infile}" \
| uniq \
| sed --expression='s/\.\///g' \
| while read language wantfile havefile; do
| while read language wantfile havefile comment; do
if [ -f "${wantfile}" ]; then
date1="$(date --iso-8601 --reference=${wantfile})"
date2="$(date --iso-8601 --reference=${havefile})"
echo "outdated ${date2} ${wantfile} ${date1} ${havefile}" >> "${infile}.${language}"
echo "outdated ${date2} ${wantfile} ${date1} ${havefile} ${comment}" >> "${infile}.${language}"
fi
done

@@ -95,7 +96,7 @@ for file in ${infile}.*; do
echo " <a href=\"translations.html\">« Back to <em>Translation status overview</em></a>"
echo " </p>"
lastgroup=""
sort --reverse ${file} | while read group date2 wantfile date1 havefile; do
sort --reverse ${file} | while read group date2 wantfile date1 havefile comment; do
if [ "${group}" != "${lastgroup}" ]; then
if [ "${group}" == "outdated" ]; then
echo " <h2>Outdated translations</h2>"
@@ -141,7 +142,7 @@ for file in ${infile}.*; do
echo " <tr>"
if [ "${group}" = "outdated" ]; then
echo " <td>"
echo " <a href=\"${srcroot}/${wantfile}\">${wantfile}</a>"
echo " <a href=\"${srcroot}/${wantfile}\">${wantfile}</a> (${comment} - <a href=\"${testroot}/${wantfile:0:${#wantfile}-5}html\">test</a>)"
echo " </td>"
echo " <td align=\"center\">${date1}</td>"
echo " <td>"
@@ -208,10 +209,10 @@ grep --no-filename "^outdated" ${infile}.* \
echo " <th colspan=\"3\">translated file</th>"
echo " <th colspan=\"3\">original file</th>"
echo " </tr>"
while read group date2 wantfile date1 havefile; do
while read group date2 wantfile date1 havefile comment; do
echo " <tr>"
echo " <td>"
echo " <a href=\"${srcroot}/${wantfile}\">${wantfile}</a>"
echo " <a href=\"${srcroot}/${wantfile}\">${wantfile}</a> (${comment})"
echo " </td>"
echo " <td align=\"center\">${date1}</td>"
echo " <td>"

Loading…
Cancel
Save